Skip to content

Instantly share code, notes, and snippets.

@rueian
Last active February 4, 2022 08:59
Show Gist options
  • Save rueian/da03cac6103d7135ec35fe8c3098e9dc to your computer and use it in GitHub Desktop.
Save rueian/da03cac6103d7135ec35fe8c3098e9dc to your computer and use it in GitHub Desktop.
func pipelining(outgoing *bufio.Writer, incoming *bufio.Reader) chan request {
requests := make(chan request, 512)
waiting := make(chan request, 512)
go func() { writing(outgoing, requests, waiting) }()
go func() { reading(incoming, waiting) }()
return requests
}
func makeRequest(requests chan request, data []byte) response {
respCh := make(chan response, 1)
requests <- request{body: data, caller: respCh}
return <-respCh
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment