Skip to content
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

Refactor single future into one future for each io operation #8

Open
andygrove opened this issue Sep 13, 2016 · 0 comments
Open

Refactor single future into one future for each io operation #8

andygrove opened this issue Sep 13, 2016 · 0 comments

Comments

@andygrove
Copy link
Contributor

andygrove commented Sep 13, 2016

Currently there is a single future which performs read + write for client + server (four distinct io operations). The code is overly complex and probably unreliable.

Suggestion is to refactor into one read future and one write future and instantiate one of each for client and server (with an enumeration to specify which one the instance is for since there is one small difference in functionality depending on the direction).

Because each future will run independently, it will be a simpler design with each future reading or writing for as long as the socket is ready and then pushing packets to the appropriate queue (client write queue or server write queue).

Taking the example of the server sending a large result set to the client, the "server read" future can be streaming packets into the "client write" queue, and the "client write" future can be streaming packets out of that queue and writing them to the client socket.

Hopefully channels can be used between futures for exchanging packets to remove the need to use mutexes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant