diff options
| author | Eli Zaretskii | 2016-12-10 18:54:43 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-12-10 18:54:43 +0200 |
| commit | 2412a1fc05fe9f89b171d0781c2d530923f48adc (patch) | |
| tree | d42a5d2608e65a10b1cc23c6b4609d54bef25d49 /src/data.c | |
| parent | fc0fd24c105bde4c001ebebe4b8b7e1f96cd2871 (diff) | |
| parent | 828b4560cd4a0d8cb9b7a7a3e20ff0c53ba86cfa (diff) | |
| download | emacs-2412a1fc05fe9f89b171d0781c2d530923f48adc.tar.gz emacs-2412a1fc05fe9f89b171d0781c2d530923f48adc.zip | |
Support concurrency in Emacs Lisp
Merge branch 'test-concurrency'
* src/thread.c:
* src/thread.h:
* src/systhread.c:
* src/systhread.h: New files.
* src/xgselect.c (xg_select): Avoid using SAFE_NALLOCA and use
xnmalloc unconditionally.
* src/window.c (struct save_window_data): Rename current_buffer to
f_current_buffer.
* src/w32proc.c (sys_select): Change the function signature to
closer fit 'pselect' on Posix hosts.
* src/search.c:
* src/regex.h: Convert some globals to macros that reference
thread-specific values.
* src/process.c (pset_thread, add_non_keyboard_read_fd)
(add_process_read_fd, add_non_blocking_write_fd)
(recompute_input_desc, compute_input_wait_mask)
(compute_non_process_wait_mask, compute_non_keyboard_wait_mask)
(compute_write_mask, clear_waiting_thread_info)
(update_processes_for_thread_death, Fset_process_thread)
(Fprocess_thread): New functions.
(enum fd_bits): New enumeration.
(fd_callback_data): Add 'thread' and 'waiting_thread', rename
'condition' to 'flags'.
(set_process_filter_masks, create_process, create_pty)
(Fmake_serial_process, finish_after_tls_connection)
(connect_network_socket, deactivate_process)
(server_accept_connection, wait_reading_process_output)
(Fcontinue_process, Fstop_process, keyboard_bit_set)
(add_timer_wait_descriptor, add_keyboard_wait_descriptor)
(delete_keyboard_wait_descriptor): Use the new functions instead
of manipulating fd flags and masks directly.
(syms_of_process): Defsubr the new primitives.
* src/print.c (print_object): Print threads, mutexes, and
conditional variables.
* src/lisp.h (enum pvec_type): New values PVEC_THREAD, PVEC_MUTEX,
and PVEC_CONDVAR.
(XTHREAD, XMUTEX, XCONDVAR, THREADP, MUTEXP, CONDVARP)
(CHECK_THREAD, CHECK_MUTEX, CHECK_CONDVAR): New inline functions.
(XSETTHREAD, XSETMUTEX, XSETCONDVAR): New macros.
(struct handler): Add back byte_stack. Rename lisp_eval_depth to
f_lisp_eval_depth.
* src/eval.c (specpdl_kind, specpdl_arg, do_specbind)
(rebind_for_thread_switch, do_one_unbind)
(unbind_for_thread_switch): New functions.
(init_eval): 'handlerlist' is not malloc'ed.
(specbind): Call do_specbind.
(unbind_to): Call do_one_unbind.
(mark_specpdl): Accept 2 arguments.
(mark_specpdl): Mark the saved value in a let-binding.
* src/emacs.c (main): Call init_threads_once, init_threads, and
syms_of_threads.
* src/data.c (Ftype_of): Support thread, mutex, and condvar
objects.
(Fthreadp, Fmutexp, Fcondition_variable_p): New functions.
(syms_of_data): DEFSYM and defsubr new symbols and primitives.
* src/bytecode.c (struct byte_stack, FETCH, CHECK_RANGE)
(BYTE_CODE_QUIT): Add back.
(exec_byte_code): Add back byte stack manipulation.
* src/alloc.c (cleanup_vector): Handle threads, mutexes, and
conditional variables.
(mark_stack): Now extern; accept additional argument 'bottom'.
(flush_stack_call_func): New function.
(garbage_collect_1): Call mark_threads and unmark_threads. Don't
mark handlers.
* src/.gdbinit (xbytecode): Add back.
* test/src/thread-tests.el: New tests.
* test/src/data-tests.el (binding-test-manual)
(binding-test-setq-default, binding-test-makunbound)
(binding-test-defvar-bool, binding-test-defvar-int)
(binding-test-set-constant-t, binding-test-set-constant-nil)
(binding-test-set-constant-keyword)
(binding-test-set-constant-nil): New tests.
* doc/lispref/processes.texi (Processes and Threads): New
subsection.
* doc/lispref/threads.texi: New file
* doc/lispref/elisp.texi (Top): Include it.
* doc/lispref/objects.texi (Thread Type, Mutex Type)
(Condition Variable Type): New subsections.
(Type Predicates): Add thread-related predicates.
* doc/lispref/objects.texi (Editing Types):
* doc/lispref/elisp.texi (Top): Update higher-level menus.
* etc/NEWS: Mention concurrency features.
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/data.c b/src/data.c index 64cd8b23b46..09d94f57a8e 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -258,6 +258,12 @@ for example, (type-of 1) returns `integer'. */) | |||
| 258 | return Qfont_entity; | 258 | return Qfont_entity; |
| 259 | if (FONT_OBJECT_P (object)) | 259 | if (FONT_OBJECT_P (object)) |
| 260 | return Qfont_object; | 260 | return Qfont_object; |
| 261 | if (THREADP (object)) | ||
| 262 | return Qthread; | ||
| 263 | if (MUTEXP (object)) | ||
| 264 | return Qmutex; | ||
| 265 | if (CONDVARP (object)) | ||
| 266 | return Qcondition_variable; | ||
| 261 | return Qvector; | 267 | return Qvector; |
| 262 | 268 | ||
| 263 | case Lisp_Float: | 269 | case Lisp_Float: |
| @@ -528,6 +534,33 @@ DEFUN ("floatp", Ffloatp, Sfloatp, 1, 1, 0, | |||
| 528 | return Qnil; | 534 | return Qnil; |
| 529 | } | 535 | } |
| 530 | 536 | ||
| 537 | DEFUN ("threadp", Fthreadp, Sthreadp, 1, 1, 0, | ||
| 538 | doc: /* Return t if OBJECT is a thread. */) | ||
| 539 | (Lisp_Object object) | ||
| 540 | { | ||
| 541 | if (THREADP (object)) | ||
| 542 | return Qt; | ||
| 543 | return Qnil; | ||
| 544 | } | ||
| 545 | |||
| 546 | DEFUN ("mutexp", Fmutexp, Smutexp, 1, 1, 0, | ||
| 547 | doc: /* Return t if OBJECT is a mutex. */) | ||
| 548 | (Lisp_Object object) | ||
| 549 | { | ||
| 550 | if (MUTEXP (object)) | ||
| 551 | return Qt; | ||
| 552 | return Qnil; | ||
| 553 | } | ||
| 554 | |||
| 555 | DEFUN ("condition-variable-p", Fcondition_variable_p, Scondition_variable_p, | ||
| 556 | 1, 1, 0, | ||
| 557 | doc: /* Return t if OBJECT is a condition variable. */) | ||
| 558 | (Lisp_Object object) | ||
| 559 | { | ||
| 560 | if (CONDVARP (object)) | ||
| 561 | return Qt; | ||
| 562 | return Qnil; | ||
| 563 | } | ||
| 531 | 564 | ||
| 532 | /* Extract and set components of lists. */ | 565 | /* Extract and set components of lists. */ |
| 533 | 566 | ||
| @@ -3756,6 +3789,9 @@ syms_of_data (void) | |||
| 3756 | DEFSYM (Qchar_table, "char-table"); | 3789 | DEFSYM (Qchar_table, "char-table"); |
| 3757 | DEFSYM (Qbool_vector, "bool-vector"); | 3790 | DEFSYM (Qbool_vector, "bool-vector"); |
| 3758 | DEFSYM (Qhash_table, "hash-table"); | 3791 | DEFSYM (Qhash_table, "hash-table"); |
| 3792 | DEFSYM (Qthread, "thread"); | ||
| 3793 | DEFSYM (Qmutex, "mutex"); | ||
| 3794 | DEFSYM (Qcondition_variable, "condition-variable"); | ||
| 3759 | 3795 | ||
| 3760 | DEFSYM (Qdefun, "defun"); | 3796 | DEFSYM (Qdefun, "defun"); |
| 3761 | 3797 | ||
| @@ -3796,6 +3832,9 @@ syms_of_data (void) | |||
| 3796 | defsubr (&Ssubrp); | 3832 | defsubr (&Ssubrp); |
| 3797 | defsubr (&Sbyte_code_function_p); | 3833 | defsubr (&Sbyte_code_function_p); |
| 3798 | defsubr (&Schar_or_string_p); | 3834 | defsubr (&Schar_or_string_p); |
| 3835 | defsubr (&Sthreadp); | ||
| 3836 | defsubr (&Smutexp); | ||
| 3837 | defsubr (&Scondition_variable_p); | ||
| 3799 | defsubr (&Scar); | 3838 | defsubr (&Scar); |
| 3800 | defsubr (&Scdr); | 3839 | defsubr (&Scdr); |
| 3801 | defsubr (&Scar_safe); | 3840 | defsubr (&Scar_safe); |