-
-
Save gobwas/85a591a21ad6fa9dedaecd8a86dbabac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ch := NewChannel(conn) | |
// Make conn to be observed by netpoll instance. | |
poller.Start(conn, netpoll.EventRead, func() { | |
// We spawn goroutine here to prevent poller wait loop | |
// to become locked during receiving packet from ch. | |
go Receive(ch) | |
}) | |
// Receive reads a packet from conn and handles it somehow. | |
func (ch *Channel) Receive() { | |
buf := bufio.NewReader(ch.conn) | |
pkt := readPacket(buf) | |
c.handle(pkt) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It should be
go ch.Receive()
right?