Skip to content
Browse files

Fixed race condition w/multiple threads trying to compute same future.

  • Loading branch information...
1 parent c4016f0 commit a03efded7b95dae3f77e2fc2e628845d3a25cf61 @vsedach committed
Showing with 2 additions and 2 deletions.
  1. +1 −1 future.lisp
  2. +1 −1 make-future.lisp
2 future.lisp
@@ -53,7 +53,7 @@ computation of the future)."
(with-lock-held ((lock future))
(when (%ready-to-yield? future)
(return-from select future))
- (when (and (not any-computing?) (computing-thread future))
+ (when (computing-thread future)
(setf any-computing? t))
(push (cons select-lock notifier) (wait-list future))))
(unless any-computing?
2 make-future.lisp
@@ -22,7 +22,7 @@ If lazy, newly created futures are not computed until asked to yield their value
(flet ((get-future () (or (weak-pointer-value future-ptr) (throw 'task-done nil))))
(let ((*computing-future* (future-id (get-future))))
(with-lock-held ((lock (get-future)))
- (if (%ready-to-yield? (get-future))
+ (if (or (%ready-to-yield? (get-future)) (computing-thread (get-future)))
(throw 'task-done nil)
(setf (computing-thread (get-future)) (current-thread))))
(finalize (get-future) (let ((thread (current-thread))

0 comments on commit a03efde

Please sign in to comment.
Something went wrong with that request. Please try again.