Skip to content

Instantly share code, notes, and snippets.

@mjg123
Created October 21, 2011 22:12
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjg123/1305115 to your computer and use it in GitHub Desktop.
Save mjg123/1305115 to your computer and use it in GitHub Desktop.
Worker Queues in Clojure
(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