+(sb!xc:defmacro with-mutex ((mutex &key value (wait-p t)) &body body)
+ #!-sb-thread (declare (ignore mutex value wait-p))
+ #!+sb-thread
+ (with-unique-names (got)
+ `(let ((,got (get-mutex ,mutex ,value ,wait-p)))
+ (when ,got
+ (unwind-protect
+ (locally ,@body)
+ (release-mutex ,mutex)))))
+ ;; KLUDGE: this separate expansion for (NOT SB-THREAD) is not
+ ;; strictly necessary; GET-MUTEX and RELEASE-MUTEX are implemented.
+ ;; However, there would be a (possibly slight) performance hit in
+ ;; using them.
+ #!-sb-thread
+ `(locally ,@body))