Skip to content

Instantly share code, notes, and snippets.

View Kungi's full-sized avatar

Andreas Klein Kungi

  • DemandFlow GmbH
  • Germany
View GitHub Profile
@gerritjvv
gerritjvv / queue offer
Created November 2, 2013 22:54
A offer function that will timeout if the offer cannot be made
(use 'clojure.core.async)
(defn offer [ch msg timeout-ms]
"Blocks till the message can be placed on the queue and returns true otherwise returns false"
(not
(nil?
(first (alts!! [(go (>! ch msg) msg) (timeout timeout-ms)])))))
;;lets test