Passing a number to chan sets the buffer size. Sends into a channel with room do not wait for a receiver. Only unbuffered and fixed buffers are supported. Dropping and sliding buffers are not.
chan
(require '[clojure.core.async :as async]) (def messages (async/chan 2)) (async/>! messages "buffered") (async/>! messages "channel") (println (async/<! messages)) (println (async/<! messages))
Both sends finish before either receive.
$ glj channel-buffering.glj buffered channel
Next example: Channel Synchronization.
A hands-on tour in the style of Go by Example. Glojure is a Clojure interpreter hosted on Go.