There have been several interesting posts about the implementation of Clojure’s core.async. This post in particular is really good, diving into the implementation and even answering some of the questions that were raised in an unrelated post that asks about the implementation of new channel types. The author takes a small go block and analyses the generated code, looking in detail at the state machine and the support code in the runtime library. Channels are based on the Handler protocol which itself is quite interesting. It allows the channel to either do its action synchronously, avoiding any blocking and letting the caller take responsibility for continuing the computation, or to instead queue a closure which will be called when a value is available. This closure is used to make the state machine take another transition when the necessary values are ready. Understanding the implementation helps one understand the trade-offs involved in using this language feature.
The author has also written this illuminating post on the timeouts available in core.async.