Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created March 9, 2021 07:08
Show Gist options
  • Save velotiotech/63ce6c8a674ded229dc3dae1681e4622 to your computer and use it in GitHub Desktop.
Save velotiotech/63ce6c8a674ded229dc3dae1681e4622 to your computer and use it in GitHub Desktop.
type hchan struct {
qcount uint // total data in the queue
dataqsiz uint // size of the circular queue
buf unsafe.Pointer // points to an array of dataqsiz elements
elemsize uint16
closed uint32
elemtype *_type // element type
sendx uint // send index
recvx uint // receive index
recvq waitq // list of recv waiters
sendq waitq // list of send waiters
// lock protects all fields in hchan, as well as several
// fields in sudogs blocked on this channel.
//
// Do not change another G's status while holding this lock
// (in particular, do not ready a G), as this can deadlock
// with stack shrinking.
lock mutex
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment