X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fthread.lisp;h=5dfb84e6eb6c0feaf5aac3d3b23193c84e0c2c5f;hb=5abf3b4b94c8c2315777e63729293395dc54992c;hp=7a2e567a02526a78193f3eeff1847a4e33028811;hpb=17fc7b64d2125ab8cb9d19c5e730c8ea5de38d1b;p=sbcl.git diff --git a/src/code/thread.lisp b/src/code/thread.lisp index 7a2e567..5dfb84e 100644 --- a/src/code/thread.lisp +++ b/src/code/thread.lisp @@ -28,7 +28,8 @@ in future versions." :type mutex) (result-lock (make-mutex :name "thread result lock") - :type mutex)) + :type mutex) + waiting-for) (def!struct mutex #!+sb-doc @@ -70,6 +71,26 @@ stale value, use MUTEX-OWNER instead." (name nil :type (or null thread-name)) (value nil)) +(sb!xc:defmacro without-thread-waiting-for ((&key already-without-interrupts) &body body) + (with-unique-names (thread prev) + (let ((without (if already-without-interrupts + 'progn + 'without-interrupts)) + (with (if already-without-interrupts + 'progn + 'with-local-interrupts))) + `(let* ((,thread *current-thread*) + (,prev (thread-waiting-for ,thread))) + (flet ((exec () ,@body)) + (if ,prev + (,without + (unwind-protect + (progn + (setf (thread-waiting-for ,thread) nil) + (,with (exec))) + (setf (thread-waiting-for ,thread) ,prev))) + (exec))))))) + (sb!xc:defmacro with-mutex ((mutex &key (value '*current-thread*) (wait-p t)) &body body) #!+sb-doc