Summary
How channels work?
- hchan struct represents channel.
- It contains circular ring buffer and mutex lock.
- Goroutines tha gets blocked on send or recv are parked in sendq or recvq.
- Go scheduler moves the blocked goroutines, out of OS thread.
- Once channel operation is complete, goroutine is moved back to local run queue.