Skip to content

Instantly share code, notes, and snippets.

@halgari
Last active February 18, 2020 16:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halgari/a874b5e8e281c3e4afe51c0249b31811 to your computer and use it in GitHub Desktop.
Save halgari/a874b5e8e281c3e4afe51c0249b31811 to your computer and use it in GitHub Desktop.
(defn unordered-pmap [threads f in-c out-c]
(let [remain (atom threads)]
(dotimes [x threads]
(go-loop []
(if-some [v (<! in-c)]
(do (>! out-c (f v))
(recur))
(if (zero? (swap! remain dec))
(close! out-c)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment