(put! port val) (put! port val fn1) (put! port val fn1 on-caller?)
Asynchronously puts a val into port, calling fn1 (if supplied) when complete, passing false iff port is already closed. nil values are not allowed. If on-caller? (default true) is true, and the put is immediately accepted, will call fn1 on calling thread. Returns true unless port is already closed.
user=> (def c (chan 1))
#'user/c
user=> (take! c
(fn [x]
(println "Clojure callback value " x)))
nil
user=> (put! c "XYZ") ; return true unless the channel is closed.
Clojure callback value XYZ
true
user=> (put! c "XYZ")
true