Skip to content

Commit f69feef

Browse files
committed
Call handler with worker pool
1 parent 7b1ed0c commit f69feef

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/cljs_workers/core.cljs

+16
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,19 @@
5959
(catch js/Object e
6060
(when fun
6161
(fun {:state :error, :error e}))))))
62+
63+
(defn do-with-pool!
64+
([pool request]
65+
(do-with-pool! pool request nil))
66+
67+
([pool {:keys [handler arguments transfer] :as request} fun]
68+
(go
69+
(let [worker
70+
(<! pool)
71+
72+
fun
73+
(fn [response]
74+
(go (>! pool worker))
75+
(when fun (fun response)))]
76+
77+
(do-with-worker! worker request fun)))))

0 commit comments

Comments
 (0)