From c8548a9470cdfea7270f05df04df5a3376e65bb7 Mon Sep 17 00:00:00 2001
From: Samuel Edwin Ward <seward@cytochro.me>
Date: Tue, 15 Nov 2011 19:06:05 -0500
Subject: [PATCH] Bug fix: FORCE no longer tries to stop computation if it has
 not started

---
 future.lisp    | 2 +-
 test/test.lisp | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/future.lisp b/future.lisp
index 0f7b25b..a8349fc 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 c0f7fc3..b85688f 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))
-- 
GitLab