Created
September 19, 2011 22:04
-
-
Save srid/1227750 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
(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