Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
selectgo loop
func selectgo(cas0 *scase, order0 *uint16, ncases int) (int, bool) {
// ...
loop:
// ...
for i := 0; i < ncases; i++ {
casi = int(pollorder[i])
cas = &scases[casi]
c = cas.c
switch cas.kind {
case caseNil:
continue
case caseRecv:
sg = c.sendq.dequeue()
if sg != nil {
goto recv
}
if c.qcount > 0 {
goto bufrecv
}
if c.closed != 0 {
goto rclose
}
case caseSend:
if c.closed != 0 {
goto sclose
}
sg = c.recvq.dequeue()
if sg != nil {
goto send
}
if c.qcount < c.dataqsiz {
goto bufsend
}
case caseDefault:
dfli = casi
dfl = cas
}
}
if dfl != nil {
selunlock(scases, lockorder)
casi = dfli
cas = dfl
goto retc
}
// ...
}
@draveness
Copy link
Author

draveness commented Mar 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment