Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 27th, 2012  |  syntax: None  |  size: 0.40 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. (def latest (ref nil))
  2. (def changelists (channel))
  3.  
  4. (receive-all changelists
  5.   (fn [changelist]
  6.     (dosync
  7.       (ref-set latest changelist))))
  8.  
  9. (defn request-handler [ch request]
  10.   (let [last-serial (-> request :body :last-serial)
  11.         src (dosync
  12.               (if (and @latest (> (:serial latest) last-serial))
  13.                 (sealed-channel @latest)
  14.                 (take* 1 changelists)))]
  15.     (siphon (map* create-http-response src) ch)))