]> git.eshelyaron.com Git - emacs.git/commitdiff
Documentation and commentary improvements
authorEli Zaretskii <eliz@gnu.org>
Sat, 10 Dec 2016 08:49:39 +0000 (10:49 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 10 Dec 2016 08:49:39 +0000 (10:49 +0200)
* src/lisp.h:
* src/regex.c:
* src/xgselect.c (xg_select): Improve commentary and formatting.

* 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.

doc/lispref/elisp.texi
doc/lispref/objects.texi
src/lisp.h
src/regex.c
src/xgselect.c

index 415dbe66fac1bd412734e393fa06ffcbeea5735a..4a53a0cd36414dcffe0406c710a905a26e389edb 100644 (file)
@@ -349,6 +349,9 @@ Editing Types
 * Window Configuration Type::  Recording the way a frame is subdivided.
 * Frame Configuration Type::   Recording the status of all frames.
 * Process Type::            A subprocess of Emacs running on the underlying OS.
+* Thread Type::             A thread of Emacs Lisp execution.
+* Mutex Type::              An exclusive lock for thread synchronization.
+* Condition Variable Type::    Condition variable for thread synchronization.
 * Stream Type::             Receive or send characters.
 * Keymap Type::             What function a keystroke invokes.
 * Overlay Type::            How an overlay is represented.
index a76fbb1af7f77202d95a129fd98814a8cbb3d3dc..5e608bcc093faa8015da9b077ea228d94abf141f 100644 (file)
@@ -1410,6 +1410,9 @@ editing.
 * Window Configuration Type::   Recording the way a frame is subdivided.
 * Frame Configuration Type::    Recording the status of all frames.
 * Process Type::        A subprocess of Emacs running on the underlying OS.
+* Thread Type::         A thread of Emacs Lisp execution.
+* Mutex Type::          An exclusive lock for thread synchronization.
+* Condition Variable Type::     Condition variable for thread synchronization.
 * Stream Type::         Receive or send characters.
 * Keymap Type::         What function a keystroke invokes.
 * Overlay Type::        How an overlay is represented.
@@ -1625,6 +1628,63 @@ giving the name of the process:
 return information about, send input or signals to, and receive output
 from processes.
 
+@node Thread Type
+@subsection Thread Type
+
+  A @dfn{thread} in Emacs represents a separate thread of Emacs Lisp
+execution.  It runs its own Lisp program, has its own current buffer,
+and can have subprocesses locked to it, i.e.@: subprocesses whose
+output only this thread can accept.  @xref{Threads}.
+
+  Thread objects have no read syntax.  They print in hash notation,
+giving the name of the thread (if it has been given a name) or its
+address in core:
+
+@example
+@group
+(all-threads)
+    @result{} (#<thread 0176fc40>)
+@end group
+@end example
+
+@node Mutex Type
+@subsection Mutex Type
+
+  A @dfn{mutex} is an exclusive lock that threads can own and disown,
+in order to synchronize between them.  @xref{Mutexes}.
+
+  Mutex objects have no read syntax.  They print in hash notation,
+giving the name of the mutex (if it has been given a name) or its
+address in core:
+
+@example
+@group
+(make-mutex "my-mutex")
+    @result{} #<mutex my-mutex>
+(make-mutex)
+    @result{} #<mutex 01c7e4e0>
+@end group
+@end example
+
+@node Condition Variable Type
+@subsection Condition Variable Type
+
+  A @dfn{condition variable} is a device for a more complex thread
+synchronization than the one supported by a mutex.  A thread can wait
+on a condition variable, to be woken up when some other thread
+notifies the condition.
+
+  Condition variable objects have no read syntax.  They print in hash
+notation, giving the name of the condition variable (if it has been
+given a name) or its address in core:
+
+@example
+@group
+(make-condition-variable (make-mutex))
+    @result{} #<condvar 01c45ae8>
+@end group
+@end example
+
 @node Stream Type
 @subsection Stream Type
 
@@ -1830,6 +1890,9 @@ with references to further information.
 @item commandp
 @xref{Interactive Call, commandp}.
 
+@item condition-variable-p
+@xref{Condition Variables, condition-variable-p}.
+
 @item consp
 @xref{List-related Predicates, consp}.
 
@@ -1875,6 +1938,9 @@ with references to further information.
 @item markerp
 @xref{Predicates on Markers, markerp}.
 
+@item mutexp
+@xref{Mutexes, mutexp}.
+
 @item wholenump
 @xref{Predicates on Numbers, wholenump}.
 
@@ -1908,6 +1974,9 @@ with references to further information.
 @item syntax-table-p
 @xref{Syntax Tables, syntax-table-p}.
 
+@item threadp
+@xref{Basic Thread Functions, threadp}.
+
 @item vectorp
 @xref{Vectors, vectorp}.
 
index 72ea50d5f27573370238c9130db6d32a9eb7a191..3c7c3dde904aaec32c72a84c92a70b82c57d0072 100644 (file)
@@ -845,6 +845,7 @@ enum pvec_type
   PVEC_THREAD,
   PVEC_MUTEX,
   PVEC_CONDVAR,
+
   /* These should be last, check internal_equal to see why.  */
   PVEC_COMPILED,
   PVEC_CHAR_TABLE,
@@ -3229,6 +3230,7 @@ union specbinding
     } bt;
   };
 
+/* These 3 are defined as macros in thread.h.  */
 /* extern union specbinding *specpdl; */
 /* extern union specbinding *specpdl_ptr; */
 /* extern ptrdiff_t specpdl_size; */
index e7231d3882bb7b0b00ff8a75f83ddb1781a60d45..f1686cf700c78a428dd4837b531acb47612831c2 100644 (file)
@@ -1140,6 +1140,7 @@ print_double_string (re_char *where, re_char *string1, ssize_t size1,
 #endif /* not DEBUG */
 \f
 #ifndef emacs
+
 /* Set by `re_set_syntax' to the current regexp syntax to recognize.  Can
    also be assigned to arbitrarily: each pattern buffer stores its own
    syntax, so it can be changed between regex compilations.  */
index e418e1a3c4efc6091370a1d49d370d31dad8aa97..2f23764ae418d29a61c39645ac14b58f38d15fad 100644 (file)
@@ -76,6 +76,9 @@ xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds,
 
   if (gfds_size < n_gfds)
     {
+      /* Avoid using SAFE_NALLOCA, as that implicitly refers to the
+        current thread.  Using xnmalloc avoids thread-switching
+        problems here.  */
       gfds = xnmalloc (n_gfds, sizeof *gfds);
       must_free = 1;
       gfds_size = n_gfds;