(in-package "SB!THREAD")
+(def!struct mutex
+ #!+sb-doc
+ "Mutex type."
+ (name nil :type (or null simple-string))
+ (value nil)
+ #!+(and sb-lutex sb-thread)
+ (lutex (make-lutex)))
+
+(def!struct spinlock
+ #!+sb-doc
+ "Spinlock type."
+ (name nil :type (or null simple-string))
+ (value 0))
+
(sb!xc:defmacro with-mutex ((mutex &key (value '*current-thread*) (wait-p t))
&body body)
#!+sb-doc
(with-unique-names (got mutex1)
`(let ((,mutex1 ,mutex)
,got)
+ (/show0 "WITH-MUTEX")
(unwind-protect
;; FIXME: async unwind in SETQ form
(when (setq ,got (get-mutex ,mutex1 ,value ,wait-p))
allowed to mix WITH-MUTEX and WITH-RECURSIVE-LOCK for the same mutex
provided the default value is used for the mutex."
#!-sb-thread
- (declare (ignore mutex)) #!+sb-thread
+ (declare (ignore mutex))
+ #!+sb-thread
(with-unique-names (mutex1 inner-lock-p)
`(let* ((,mutex1 ,mutex)
(,inner-lock-p (eq (mutex-value ,mutex1) *current-thread*)))