summaryrefslogtreecommitdiff
path: root/devdocs/elisp/threads.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/threads.html')
-rw-r--r--devdocs/elisp/threads.html26
1 files changed, 26 insertions, 0 deletions
diff --git a/devdocs/elisp/threads.html b/devdocs/elisp/threads.html
new file mode 100644
index 00000000..0709f40a
--- /dev/null
+++ b/devdocs/elisp/threads.html
@@ -0,0 +1,26 @@
+ <h2 class="chapter">Threads</h2> <p>Emacs Lisp provides a limited form of concurrency, called <em>threads</em>. All the threads in a given instance of Emacs share the same memory. Concurrency in Emacs Lisp is “mostly cooperative”, meaning that Emacs will only switch execution between threads at well-defined times. However, the Emacs thread support has been designed in a way to later allow more fine-grained concurrency, and correct programs should not rely on cooperative threading. </p> <p>Currently, thread switching will occur upon explicit request via <code>thread-yield</code>, when waiting for keyboard input or for process output from asynchronous processes (e.g., during <code>accept-process-output</code>), or during blocking operations relating to threads, such as mutex locking or <code>thread-join</code>. </p> <p>Emacs Lisp provides primitives to create and control threads, and also to create and control mutexes and condition variables, useful for thread synchronization. </p> <p>While global variables are shared among all Emacs Lisp threads, local variables are not—a dynamic <code>let</code> binding is local. Each thread also has its own current buffer (see <a href="current-buffer">Current Buffer</a>) and its own match data (see <a href="match-data">Match Data</a>). </p> <p>Note that <code>let</code> bindings are treated specially by the Emacs Lisp implementation. There is no way to duplicate this unwinding and rewinding behavior other than by using <code>let</code>. For example, a manual implementation of <code>let</code> written using <code>unwind-protect</code> cannot arrange for variable values to be thread-specific. </p> <p>In the case of lexical bindings (see <a href="variable-scoping">Variable Scoping</a>), a closure is an object like any other in Emacs Lisp, and bindings in a closure are shared by any threads invoking the closure. </p> <table class="menu" border="0" cellspacing="0"> <tr>
+<td align="left" valign="top">• <a href="basic-thread-functions" accesskey="1">Basic Thread Functions</a>
+</td>
+<td> </td>
+<td align="left" valign="top">Basic thread functions. </td>
+</tr> <tr>
+<td align="left" valign="top">• <a href="mutexes" accesskey="2">Mutexes</a>
+</td>
+<td> </td>
+<td align="left" valign="top">Mutexes allow exclusive access to data. </td>
+</tr> <tr>
+<td align="left" valign="top">• <a href="condition-variables" accesskey="3">Condition Variables</a>
+</td>
+<td> </td>
+<td align="left" valign="top">Inter-thread events. </td>
+</tr> <tr>
+<td align="left" valign="top">• <a href="the-thread-list" accesskey="4">The Thread List</a>
+</td>
+<td> </td>
+<td align="left" valign="top">Show the active threads. </td>
+</tr> </table><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
+ <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Threads.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Threads.html</a>
+ </p>
+</div>