diff options
| author | Michael Albinus | 2018-07-17 12:03:43 +0200 |
|---|---|---|
| committer | Michael Albinus | 2018-07-17 12:03:43 +0200 |
| commit | 798cbac170f05a749a4d5130d64d83c202f09158 (patch) | |
| tree | 8541cd26117f0aee8bc02612f98d99fe49127ef2 /src/thread.c | |
| parent | 94a16e7360b69191001bc594ab1b66f2b6bf97c2 (diff) | |
| download | emacs-798cbac170f05a749a4d5130d64d83c202f09158.tar.gz emacs-798cbac170f05a749a4d5130d64d83c202f09158.zip | |
Add variable main-thread, fix Bug#32169
* doc/lispref/threads.texi (Basic Thread Functions): Add example,
how to propagate signals to the main thread. Describe variable
`main-thread'. Document optional argument CLEANUP of
`thread-last-error'.
* src/thread.c (Fthread_last_error): Add optional argument
CLEANUP. (Bug#32169)
(main-thread): New defvar.
* test/src/thread-tests.el (thread-last-error): Adapt declaration.
(main-thread): Declare.
(threads-main-thread): New test.
(threads-errors): Extend test.
Diffstat (limited to 'src/thread.c')
| -rw-r--r-- | src/thread.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/thread.c b/src/thread.c index 3eba25b7b43..754d286e9f8 100644 --- a/src/thread.c +++ b/src/thread.c | |||
| @@ -973,11 +973,17 @@ DEFUN ("all-threads", Fall_threads, Sall_threads, 0, 0, 0, | |||
| 973 | return result; | 973 | return result; |
| 974 | } | 974 | } |
| 975 | 975 | ||
| 976 | DEFUN ("thread-last-error", Fthread_last_error, Sthread_last_error, 0, 0, 0, | 976 | DEFUN ("thread-last-error", Fthread_last_error, Sthread_last_error, 0, 1, 0, |
| 977 | doc: /* Return the last error form recorded by a dying thread. */) | 977 | doc: /* Return the last error form recorded by a dying thread. |
| 978 | (void) | 978 | If CLEANUP is non-nil, remove this error form from history. */) |
| 979 | (Lisp_Object cleanup) | ||
| 979 | { | 980 | { |
| 980 | return last_thread_error; | 981 | Lisp_Object result = last_thread_error; |
| 982 | |||
| 983 | if (!NILP (cleanup)) | ||
| 984 | last_thread_error = Qnil; | ||
| 985 | |||
| 986 | return result; | ||
| 981 | } | 987 | } |
| 982 | 988 | ||
| 983 | 989 | ||
| @@ -1083,4 +1089,13 @@ syms_of_threads (void) | |||
| 1083 | DEFSYM (Qthreadp, "threadp"); | 1089 | DEFSYM (Qthreadp, "threadp"); |
| 1084 | DEFSYM (Qmutexp, "mutexp"); | 1090 | DEFSYM (Qmutexp, "mutexp"); |
| 1085 | DEFSYM (Qcondition_variable_p, "condition-variable-p"); | 1091 | DEFSYM (Qcondition_variable_p, "condition-variable-p"); |
| 1092 | |||
| 1093 | DEFVAR_LISP ("main-thread", | ||
| 1094 | Vmain_thread, | ||
| 1095 | doc: /* The main thread of Emacs. */); | ||
| 1096 | #ifdef THREADS_ENABLED | ||
| 1097 | XSETTHREAD (Vmain_thread, &main_thread); | ||
| 1098 | #else | ||
| 1099 | Vmain_thread = Qnil; | ||
| 1100 | #endif | ||
| 1086 | } | 1101 | } |