|
|
|
|
|
by stock_toaster
4988 days ago
|
|
Thanks. I think I understand a bit better now. Go provides concurrency primitives (scheduler yielding i/o, channels, goroutines, etc) upon which you can build your own "events". I agree (and this seems to be your point) that Go doesn't provide a canned event mechanism that you can just hook into for callbacks on IO. For example in the Go http server[1] a goroutine accepts in a loop and kicks off goroutines to process and handle new requests. [1]: http://golang.org/src/pkg/net/http/server.go?s=30200:30241#L... |
|
Take the example of a simple proxy to see where I'm coming from. Sure, I'm happy to have Go manage all the connections and sockets and I'm happy to spawn new goroutines for each connection and all that. But a proxy accepts an inbound connection, makes an outbound connection, and then monitors the outbound and inbound sides for data. The loop to do this with sockets could be a simple two-descriptor read select(2) call. But instead, I have to spawn two more goroutines, one to "monitor" (really, read) from inbound, and one for outbound.