I've read this great article about core.async here:
http://www.core-async.info/reference/primitives
I'm struggling to understand the internal mechanic of put! and go. I understand that:
- put! is asynchronous and can accept a callback. That works well in simple scenarios, but you can end in a callback hell.
- go fixes the callback hell, and allows to write asynchronous code in a synchronous style.
- go leverages a lightweight thread-pool, and leverages parking to enable concurrency.
- go uses a finite state-machine
I don't understand:
- How does put! achieve asynchrony? Does it also uses a thread-pool?
- Does put! also uses parking?
- What is the role of the finite state-machine in the go block? Is it what enables parking?
- Should I always try to use put! rather than go because it is cheaper? In that case, does that mean that put! achieve the exact same concurrency goodness as go, and that go is only used when I want to reason about complex asynchronous code?
Thanks a lot for shedding the lights on those mysteries.