Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn start-handler [[nme definition]]
- (let [queue (new LinkedBlockingQueue)
- handler (:handler definition)
- condition (:cond definition)
- name (str "handler" nme)]
- (println "starting" name)
- (start-thread #(handler (queue-seq queue)) name)
- #(if (condition %) (.put queue %))))
- (defn filter-with-date [e]
- (not
- (or (nil? (:date e))
- (= (:name e) "-"))))
- (defn printer []
- (struct-map handler
- :cond filter-with-date
- :handler (fn [es]
- (doseq [e es]
- (println e)))))
- ; with a different thread doing
- (start-handler [:print-handler (printer)])
- ; and shoving items onto the LBQ with the returned function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement