-
Notifications
You must be signed in to change notification settings - Fork 735
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
Remove Registration
and SetReadiness
APIs
#907
Comments
The windows selector uses |
@carllerche is the plan to keep the existing |
As I know of, |
@eduardosm The current plan (which is a work in progress, for which we're looking for feedback) is to reduce the API service of Mio. Anything that can be implemented outside of Mio, should be implemented outside mio. This includes user space notifications, which is currently implemented as If your goal is just to wake poll from another thread then your implementation of the |
@eduardosm @Thomasdezeeuw I think there will need to be some public awakener API. That is the only thing needed to impl |
Thinking more about it, technically an awakener could be implemented in userland, but I am not sure if that is a good idea or not. #788 proposes reserving token space for selector implementation. This would allow OS specific selectors to provide additional features as needed. Reserving a token for the awakener was also part of the intent for this. I'm leaning towards keeping an awakener concept part of core mio because a) it is pretty much always needed to have a way to wake up an event loop b) the implementation it is pretty platform specific. |
My main concern with removing |
I've been thinking about this a bit lately and I came to the conclusion that an pub struct Awakener {
inner: sys::Awakener,
}
impl Awakener {
/// Create a new `Awakener`.
pub fn new(poll: &Poll, token: Token) -> io::Result<Awakener> {
Ok(Awakener { inner: sys::Awakener::new(poll, token)? })
}
/// Attempts to clone the `Awakener`.
///
/// The `Awakener` must first be registered with a `Poller` instance before
/// it can be cloned.
pub fn try_clone(&self) -> io::Result<Awakener> {
self.inner.try_clone()
}
/// Wake up the `Poller` associated (registered) with this `Awakener`.
pub fn wake(&self) -> io::Result<()> {
self.inner.wake()
}
/// Drain the `Awakener` of all notifications.
pub fn drain(&self) -> io::Result<()> {
// Only really needed on Linux to not overflow 64 bits.
self.inner.drain()
}
}
impl Evented for Awakener {
// ...
} // sys module.
pub struct sys::Awakener {
// On linux we use eventfd.
#[cfg(target_os = "linux")]
efd: RawFd,
// Kqueue platforms need a copy of the kqueue file descriptor.
#[cfg(any(target_os = "freebsd", target_os = "macos",
target_os = "netbsd", target_os = "openbsd"))]
kq: RawFd,
// Other unix platforms use a pipe.
#[cfg(target_os = "NOT_ABOVE")]
pfd: RawFd,
} I'll do some experiments with kqueue, @eduardosm already implemented Linux's eventfd. Who can do Windows? |
I've implemented this for mio-st in pr Thomasdezeeuw/gaea#45. The API changed slightly;
I've updated my previous comment. |
Ok so the pr is failing sometimes and only on Linux. @eduardosm Do you know why it could miss an event from the |
One question: Do we still want to support linux kernel 2.6.18? Last I checked (years ago) it was still in heavy use. eventfd is not available on this kernel. |
I think the answer is no, we can probably just copy this as a goal for supported platforms. |
First, make Registration/SetReadiness private.
Just a question, to make sure I correctly understood this change. This does effectively remove the capability to craft purely userspace event sources that would be recognized by mio, right? So, the path forward to keep using them (like the ones provided by Is that correct? |
@vberger yes, that is correct. User space events are consider out-of-scope for Mio 0.7. |
@vberger your suggested solution how more or less how I handle user space as well. |
@Thomasdezeeuw @vberger Did any of you made a crate that replaces |
@nox I don't know how Servo used |
Sorry I meant that |
@nox No, I instead stopped depending on mio-extras and implemented internally what I needed for managing purely userspace event sources. |
The
Registration
andSetReadiness
APIs require maintaining a custom scheduler internal to Mio. The ecosystem is moving away from using the Mio scheduler. For example, Tokio provides a number of its own schedulers.By removing these APIs, Mio on *nix platforms will (again) truely become zero cost on top of the OS APIs.
The text was updated successfully, but these errors were encountered: