Function: with-mutex
with-mutex is a macro defined in subr.el.gz.
Signature
(with-mutex MUTEX &rest BODY)
Documentation
Invoke BODY with MUTEX held, releasing MUTEX when done.
This is the simplest safe way to acquire and release a mutex.
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
;;; 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)))))