diff --git a/future.lisp b/future.lisp index 0f7b25be12932d1f371b1068a2fe6bc78d828d14..a8349fc1e28133e302abf7519818951820788b7c 100644 --- a/future.lisp +++ b/future.lisp @@ -31,7 +31,7 @@ computation of the future)." (return-from force nil) (setf (%values future) values))) (with-slots (computing-thread) future - (unless (eq computing-thread (current-thread)) + (unless (or (null computing-thread) (eq computing-thread (current-thread))) (abort-scheduled-future-task computing-thread (future-id future))) (dolist (x (wait-list future)) (with-lock-held ((car x)) diff --git a/test/test.lisp b/test/test.lisp index c0f7fc31651d35ea25f18ea0b19499a9b7e50635..b85688f67b11162700236b1585a769cabd275f88 100644 --- a/test/test.lisp +++ b/test/test.lisp @@ -75,6 +75,12 @@ (sleep 0.2) (and flag (yield foo)))))) +(test force-unstarted + (is (= 1 + (let ((future (pcall (constantly 5) :lazy))) + (force future 1) + (yield future))))) + (test gc-future (is (= 1 (let ((foo 1))