microsoft/go-winio

Integrate with the Go runtime’s event loop

Opened this issue · 3 comments

This is a feature request for integration with the Go runtime’s event loop. This would mean that operations appeared to block, but in fact did not, just like with the rest of Go.

tmm1 commented

I believe this is already the case.. all the APIs in this package block, and use channels under the hood to communicate with the completion port. The wrappers provided even conform to common golang interfaces like io.Reader and io.Writer.

I don't think this is true for the code that establishes the connection using waitNamedPIpe. Once the connection is established, read/write should behave as you indicate.

I'm not sure it would be easy to make waitNamedPipe behave like you say. But I think it would be easier and probably better to just do a sleep (e.g. 100ms) and wake loop. That should behave well with go.

My pull request #80 eliminates the use of waitNamedPipe, and so consequently should completely address this issue -- all the other uses in the code use IO completion ports sensibly to play well with the go runtime.