Created
October 21, 2011 22:12
-
-
Save mjg123/1305115 to your computer and use it in GitHub Desktop.
Worker Queues in Clojure
This file contains hidden or 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
(defn new-q [] (java.util.concurrent.LinkedBlockingDeque.)) | |
(defn offer! | |
"adds x to the back of queue q" | |
[q x] (.offer q x) q) | |
(defn take! | |
"takes from the front of queue q. if q is empty, block until something is offer!ed into it" | |
[q] (.take q)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment