X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fthread.lisp;h=367b90dcf7e7e9c33a676cad82ec4af0d46cc166;hb=cf0b72cd4052a09b9a305081524bd44e2948c1e5;hp=d327ce9b92db7476a1bc543c04d26c04992c65f7;hpb=5d811ef35f080723cfe2aacd128db320620c759c;p=sbcl.git diff --git a/src/code/thread.lisp b/src/code/thread.lisp index d327ce9..367b90d 100644 --- a/src/code/thread.lisp +++ b/src/code/thread.lisp @@ -23,7 +23,7 @@ #!+sb-doc "Spinlock type." (name nil :type (or null simple-string)) - (value 0)) + (value nil)) (sb!xc:defmacro with-mutex ((mutex &key (value '*current-thread*) (wait-p t)) &body body) @@ -74,6 +74,22 @@ provided the default value is used for the mutex." #!-sb-thread `(locally ,@body)) +(sb!xc:defmacro with-recursive-spinlock ((spinlock) &body body) + #!-sb-thread + (declare (ignore spinlock)) + #!+sb-thread + (with-unique-names (lock inner-lock-p got-it) + `(let* ((,lock ,spinlock) + (,inner-lock-p (eq (spinlock-value ,lock) *current-thread*)) + (,got-it nil)) + (unwind-protect + (when (or ,inner-lock-p (setf ,got-it (get-spinlock ,lock))) + (locally ,@body)) + (when ,got-it + (release-spinlock ,lock))))) + #!-sb-thread + `(locally ,@body)) + (sb!xc:defmacro with-spinlock ((spinlock) &body body) #!-sb-thread (declare (ignore spinlock))