Grokking Concurrency in Go
Vote

0% completed

​

How Channels Work Inside

A channel is a value that points to a single structure in the runtime, and that structure is called hchan. It holds a lock, a fixed-size ring of slots for buffered values, and two lists of goroutines that are waiting: one for senders and one for receivers. Every send, receive, and close on the channel takes the lock, changes some of those fields, and releases the lock.

Because a channel value is only a pointer, copying it copies the pointer. Two goroutines that each hold a copy of ch therefore work on the same hchan

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content