Skip to content

Instantly share code, notes, and snippets.

@halgari
Last active December 26, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halgari/7226915 to your computer and use it in GitHub Desktop.
Save halgari/7226915 to your computer and use it in GitHub Desktop.
(let [take-c (chan 1)]
(go
(loop [pending []
tout (timeout 1000)]
(alt! [take-c] ([v] (let [new-pending (conj pending v)]
(if (> max-pending (count new-pending))
(do (thread (process-stuff pending))
(recur [] (timeout 1000)))
(recur new-pending tout))))
[tout] ([_]
(thread (process-stuff pending))
(recur [] (timeout 1000)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment