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 /doc | |
| 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 'doc')
| -rw-r--r-- | doc/lispref/threads.texi | 19 |
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, | |||
| 87 | If @var{thread} was blocked by a call to @code{mutex-lock}, | 87 | If @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} |
| 89 | will unblock it. | 89 | will unblock it. |
| 90 | |||
| 91 | Since signal handlers in Emacs are located in the main thread, a | ||
| 92 | signal must be propagated there in order to become visible. The | ||
| 93 | second @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 | |||
| 127 | by each invocation. | 136 | by each invocation. |
| 128 | @end defun | 137 | @end defun |
| 129 | 138 | ||
| 139 | @defvar main-thread | ||
| 140 | This variable keeps the main thread Emacs is running, or @code{nil} if | ||
| 141 | Emacs is compiled without thread support. | ||
| 142 | @end defvar | ||
| 143 | |||
| 130 | When code run by a thread signals an error that is unhandled, the | 144 | When code run by a thread signals an error that is unhandled, the |
| 131 | thread exits. Other threads can access the error form which caused | 145 | thread exits. Other threads can access the error form which caused |
| 132 | the thread to exit using the following function. | 146 | the thread to exit using the following function. |
| 133 | 147 | ||
| 134 | @defun thread-last-error | 148 | @defun thread-last-error &optional cleanup |
| 135 | This function returns the last error form recorded when a thread | 149 | This function returns the last error form recorded when a thread |
| 136 | exited due to an error. Each thread that exits abnormally overwrites | 150 | exited due to an error. Each thread that exits abnormally overwrites |
| 137 | the form stored by the previous thread's error with a new value, so | 151 | the form stored by the previous thread's error with a new value, so |
| 138 | only the last one can be accessed. | 152 | only the last one can be accessed. If @var{cleanup} is |
| 153 | non-@code{nil}, the stored form is reset to @code{nil}. | ||
| 139 | @end defun | 154 | @end defun |
| 140 | 155 | ||
| 141 | @node Mutexes | 156 | @node Mutexes |