SHARE
TWEET

Untitled

a guest Feb 27th, 2012 23 Never
  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)))
RAW Paste Data
Top