Skip to content

Instantly share code, notes, and snippets.

@rueian
Created February 4, 2022 09:35
Show Gist options
  • Save rueian/e0723348ab6bd5f08229b4cd073d6f02 to your computer and use it in GitHub Desktop.
Save rueian/e0723348ab6bd5f08229b4cd073d6f02 to your computer and use it in GitHub Desktop.
func writing(outgoing *bufio.Writer, queue *ring) (err error) {
var req request
var ok bool
for err == nil {
if req, ok = queue.NextRequestToSend(); ok {
_, err = outgoing.Write(req.body)
} else {
err = outgoing.Flush()
runtime.Gosched()
}
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment