Skip to content

Commit

Permalink
Call handler with worker pool
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkDvlp committed Feb 24, 2017
1 parent 7b1ed0c commit f69feef
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/cljs_workers/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,19 @@
(catch js/Object e
(when fun
(fun {:state :error, :error e}))))))

(defn do-with-pool!
([pool request]
(do-with-pool! pool request nil))

([pool {:keys [handler arguments transfer] :as request} fun]
(go
(let [worker
(<! pool)

fun
(fn [response]
(go (>! pool worker))
(when fun (fun response)))]

(do-with-worker! worker request fun)))))

0 comments on commit f69feef

Please sign in to comment.