Skip to content

Instantly share code, notes, and snippets.


Created Dec 18, 2012
What would you like to do?
(defn pipe
"Returns a vector containing a sequence that will read from the
queue, and a function that inserts items into the queue.
(let [q (LinkedBlockingQueue.)
EOQ (Object.)
NIL (Object.)
s (fn queue-seq []
(lazy-seq (let [x (.take q)]
(when-not (= EOQ x)
(cons (when-not (= NIL x) x)
[(s) (fn queue-put
([] (.put q EOQ))
([x] (.put q (or x NIL))))]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.