diff options
Diffstat (limited to 'lisp/subr.el')
| -rw-r--r-- | lisp/subr.el | 14 | 
1 files changed, 14 insertions, 0 deletions
| diff --git a/lisp/subr.el b/lisp/subr.el index 7d4409e3167..952453a9cc0 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4953,6 +4953,20 @@ as a list.")            "-pkg.el")) +;;; Thread support. + +(defmacro with-mutex (mutex &rest body) +  "Invoke BODY with MUTEX held, releasing MUTEX when done. +This is the simplest safe way to acquire and release a mutex." +  (declare (indent 1) (debug t)) +  (let ((sym (make-symbol "mutex"))) +    `(let ((,sym ,mutex)) +       (mutex-lock ,sym) +       (unwind-protect +	   (progn ,@body) +	 (mutex-unlock ,sym))))) + +  ;;; Misc.  (defvar definition-prefixes (make-hash-table :test 'equal) | 
