Skip to content

Commit 651594c

Browse files
committed
make let-flow wait on all bound values, fix #118
1 parent 193f5f4 commit 651594c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/manifold/deferred.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,12 +1306,14 @@
13061306
(back-references marker form)))
13071307
(range))))
13081308
binding-dep? (->> gensym->deps vals (apply concat) set)
1309+
13091310
body-dep? (->> `(let [~@(interleave
13101311
vars'
13111312
(repeat nil))]
13121313
~@body)
13131314
(back-references marker)
13141315
(map (zipmap vars' gensyms))
1316+
(concat (drop (count vars) gensyms))
13151317
set)
13161318
dep? (set/union binding-dep? body-dep?)]
13171319
`(let [executor# (manifold.executor/executor)]

test/manifold/deferred_test.clj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@
7373
(d/catch ArithmeticException (constantly :foo))))))
7474

7575
(deftest test-let-flow
76+
77+
(let [flag (atom false)]
78+
@(let [z (clojure.core/future 1)]
79+
(d/let-flow [x (d/future (clojure.core/future z))
80+
_ (d/future (Thread/sleep 1000) (reset! flag true))
81+
y (d/future (+ z x))]
82+
(d/future (+ x x y z))))
83+
(is (= true @flag)))
84+
7685
(is (= 5
7786
@(let [z (clojure.core/future 1)]
7887
(d/let-flow [x (d/future (clojure.core/future z))

0 commit comments

Comments
 (0)