core.async is an exciting new library to organize and rationalize highly concurrent applications in Clojure. Presented at the Portland Java User's Group.
(<! query3)] (send-response data1 data2 data3))) Executes in pooled thread Reads value or parks (defn request-handler [request] (let [result (go …)] (<!! result))) Final result available through channel
request-channel) _ (<! (timeout 50)) response {:data (* 2 (:data request))}] (>! response-channel response)))) nil) Client sends the request and a channel for the response
disk-cache-channel [ticker-name disk-response-channel]) api-response-channel (chan 1) _ (!> api-channel [ticker-name api-response-channel]) [stock-value from-channel] (alts! [disk-response-channel api-response-channel (timeout 200)])] (if stock-value (:price stock-value) :unknown)))) alts! returns the value and the channel that provided the value
request-channel ([[request response-channel]] (let [_ (<! (timeout 50)) response {:data (* 2 (:data request))}] (>! response-channel response) (recur))) :priority true)))) Could be a go block, or function that uses a go block
allowed on a single channel. Consider using a windowed buffer. (< (.size puts) impl/MAX-QUEUE-SIZE) at clojure.core.async.impl.channels.ManyToManyChannel.put_BANG_(channels.clj: 95) at clojure.core.async.impl.ioc_macros$put_BANG_.invoke(ioc_macros.clj: 824) at poc.async_alts$get_answer $fn__1764$state_machine__1239__auto____1765.invoke(async_alts.clj:23) at clojure.core.async.impl.ioc_macros $run_state_machine.invoke(ioc_macros.clj:812) at poc.async_alts$get_answer$fn__1764.invoke(async_alts.clj:23) at clojure.lang.AFn.run(AFn.java:24) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1145) at java.util.concurrent.ThreadPoolExecutor $Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724)