aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorMichael Albinus2018-07-17 12:03:43 +0200
committerMichael Albinus2018-07-17 12:03:43 +0200
commit798cbac170f05a749a4d5130d64d83c202f09158 (patch)
tree8541cd26117f0aee8bc02612f98d99fe49127ef2 /doc
parent94a16e7360b69191001bc594ab1b66f2b6bf97c2 (diff)
downloademacs-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 'doc')
-rw-r--r--doc/lispref/threads.texi19
1 files changed, 17 insertions, 2 deletions
diff --git a/doc/lispref/threads.texi b/doc/lispref/threads.texi
index f05af496188..4cef9c9c6e8 100644
--- a/doc/lispref/threads.texi
+++ b/doc/lispref/threads.texi
@@ -87,6 +87,15 @@ thread, then this just calls @code{signal} immediately. Otherwise,
87If @var{thread} was blocked by a call to @code{mutex-lock}, 87If @var{thread} was blocked by a call to @code{mutex-lock},
88@code{condition-wait}, or @code{thread-join}; @code{thread-signal} 88@code{condition-wait}, or @code{thread-join}; @code{thread-signal}
89will unblock it. 89will unblock it.
90
91Since signal handlers in Emacs are located in the main thread, a
92signal must be propagated there in order to become visible. The
93second @code{signal} call let the thread die:
94
95@example
96(thread-signal main-thread 'error data)
97(signal 'error data)
98@end example
90@end defun 99@end defun
91 100
92@defun thread-yield 101@defun thread-yield
@@ -127,15 +136,21 @@ Return a list of all the live thread objects. A new list is returned
127by each invocation. 136by each invocation.
128@end defun 137@end defun
129 138
139@defvar main-thread
140This variable keeps the main thread Emacs is running, or @code{nil} if
141Emacs is compiled without thread support.
142@end defvar
143
130When code run by a thread signals an error that is unhandled, the 144When code run by a thread signals an error that is unhandled, the
131thread exits. Other threads can access the error form which caused 145thread exits. Other threads can access the error form which caused
132the thread to exit using the following function. 146the thread to exit using the following function.
133 147
134@defun thread-last-error 148@defun thread-last-error &optional cleanup
135This function returns the last error form recorded when a thread 149This function returns the last error form recorded when a thread
136exited due to an error. Each thread that exits abnormally overwrites 150exited due to an error. Each thread that exits abnormally overwrites
137the form stored by the previous thread's error with a new value, so 151the form stored by the previous thread's error with a new value, so
138only the last one can be accessed. 152only the last one can be accessed. If @var{cleanup} is
153non-@code{nil}, the stored form is reset to @code{nil}.
139@end defun 154@end defun
140 155
141@node Mutexes 156@node Mutexes