Skip to content

Allow concurrent readers #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nhooyr opened this issue Sep 22, 2019 · 2 comments
Closed

Allow concurrent readers #145

nhooyr opened this issue Sep 22, 2019 · 2 comments

Comments

@nhooyr
Copy link
Contributor

nhooyr commented Sep 22, 2019

It'd be nice if concurrent readers worked the same way concurrent writers do.

i.e right now if I wanted to spawn a pool of goroutines to read messages from a WebSocket and respond to them, I'd need to spawn an extra goroutine to read the messages and then pipe them to the workers via a channel. It'd be simpler if the library just automatically blocked additional Reader calls until previous readers were closed.

@nhooyr
Copy link
Contributor Author

nhooyr commented Sep 22, 2019

Also need to ensure NetConn can be accessed concurrently on all methods, it doesn't look like it Read at least can.

@nhooyr
Copy link
Contributor Author

nhooyr commented Sep 22, 2019

Looks like the reason I never allowed this is because you want to set a timeout between every message, not a timeout on a single worker waiting for a message. Fixed the NetConn bug though.

@nhooyr nhooyr closed this as completed Sep 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant