Skip to content

Instantly share code, notes, and snippets.

@rueian
Created February 4, 2022 09:28
Show Gist options
  • Save rueian/b2cb324c15f8a2571401e06b20c9a820 to your computer and use it in GitHub Desktop.
Save rueian/b2cb324c15f8a2571401e06b20c9a820 to your computer and use it in GitHub Desktop.
func (r *ring) NextRequestToSend() (req request, ok bool) {
s := &r.slots[(r.read1+1)&1023]
if ok = atomic.LoadUint32(&s.mark) == 2; ok {
req = s.req
r.read1++
atomic.StoreUint32(&s.mark, 3)
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment