(setf (thread-waiting-for thread) nil)
(let ((head (waitqueue-%head queue)))
(do ((list head (cdr list))
- (prev nil))
- ((eq (car list) thread)
- (let ((rest (cdr list)))
- (cond (prev
- (setf (cdr prev) rest))
- (t
- (setf (waitqueue-%head queue) rest
- prev rest)))
- (unless rest
- (setf (waitqueue-%tail queue) prev))))
- (setf prev list)))
+ (prev nil list))
+ ((or (null list)
+ (eq (car list) thread))
+ (when list
+ (let ((rest (cdr list)))
+ (cond (prev
+ (setf (cdr prev) rest))
+ (t
+ (setf (waitqueue-%head queue) rest
+ prev rest)))
+ (unless rest
+ (setf (waitqueue-%tail queue) prev)))))))
nil)
(defun %waitqueue-wakeup (queue n)
(declare (fixnum n))
(setf status
(or (flet ((wakeup ()
(barrier (:read))
- (when (neq queue
- (thread-waiting-for me))
+ (unless (eq queue (thread-waiting-for me))
:ok)))
(declare (dynamic-extent #'wakeup))
(allow-with-interrupts
(setf (thread-waiting-for ,thread) nil)
(barrier (:write))
(,with (exec)))
- (setf (thread-waiting-for ,thread) ,prev)
- (barrier (:write))))
+ ;; If we were waiting on a waitqueue, this becomes a bogus
+ ;; wakeup.
+ (when (mutex-p ,prev)
+ (setf (thread-waiting-for ,thread) ,prev)
+ (barrier (:write)))))
(exec)))))))
(sb!xc:defmacro with-mutex ((mutex &key (value '*current-thread*) (wait-p t))