-
Notifications
You must be signed in to change notification settings - Fork 716
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
ReadHint
in the readable
callback of Handler
#4
Milestone
Comments
Just as a follow-up, I expect three usage patterns:
|
wycats
added a commit
that referenced
this issue
Sep 8, 2014
Closes #4. We will also need to move IoError to a hint, since it's not supported by all backends.
wycats
added a commit
that referenced
this issue
Sep 9, 2014
Closes #4. We will also need to move IoError to a hint, since it's not supported by all backends.
wycats
added a commit
that referenced
this issue
Sep 9, 2014
Closes #4. We will also need to move IoError to a hint, since it's not supported by all backends.
wycats
added a commit
that referenced
this issue
Oct 4, 2014
This implements the first part of the strategy outlined in #4. It updates the tests to take the read hint in the handlers, and specifically confirm that they get the DataHint first and then the HupHint. I believe that the hints are implementable on all of the backends we intend to support, so I consider it a bug if those tests don't pass on a supported platform. Note that this information is called a "hint" because you still need to handle errors in your read handler, but this may allow you to skip the extra `read` syscall as an optimization.
wycats
added a commit
that referenced
this issue
Oct 6, 2014
This implements the first part of the strategy outlined in #4. Closes #4. It updates the tests to take the read hint in the handlers, and specifically confirm that they get the DataHint first and then the HupHint. I believe that the hints are implementable on all of the backends we intend to support, so I consider it a bug if those tests don't pass on a supported platform. Note that this information is called a "hint" because you still need to handle errors in your read handler, but this may allow you to skip the extra `read` syscall as an optimization.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In #3, @rrichardson suggested that it would be useful for handlers to know when the remote side of a socket hangs up.
The
epoll
backend can support this via theEPOLLHUP
andEPOLLRDHUP
, but other backends do not expose this directly (and instead require the user to attempt to read from the fd to discover that the other side hung up). If this information is directly available, it can be useful as an optimization, even in portable code.Since we want mio to make it easy to write portable code, it would be better not to expose this as an additional callback on Handler. If we did that, people who wanted to write portable code would have to write duplicate code in backend-specific handlers.
Instead, I suggest that we add a new parameter to the
readable
callback that provides backend-specific information if it's available. Since its goal is to make it easy to optimize portable code, in general, and cannot be generally relied on, I suggest calling an enum calledReadableHint
.The text was updated successfully, but these errors were encountered: