Skip to content

Instantly share code, notes, and snippets.

@srid
Created September 19, 2011 22:04
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 srid/1227750 to your computer and use it in GitHub Desktop.
Save srid/1227750 to your computer and use it in GitHub Desktop.
(def *recently-popped* (ref nil))
(defn pop-log
"Pop the oldest entry from the log; return nil if none available"
[]
(when-not (empty? @incoming-log)
;; wait till last update of incoming-log is done
(while (and (not (nil? @*recently-popped*))
(= @*recently-popped* (peek @incoming-log)))
(Thread/sleep 100))
(let [peeked (peek @incoming-log)]
(send incoming-log pop)
(dosync (alter *recently-popped* (fn [_] peeked)))
peeked)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment