Last active
December 26, 2015 22:59
-
-
Save halgari/7226915 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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