tokio-reactor: impl AsRawFd for reactor for unix (#890)

In order to support nesting a tokio reactor within another event
system exposing the file descriptor for the underlying reactor
is useful and is already implemented for mio::Poll.

Signed-off-by: Paul Osborne <[email protected]>
This commit is contained in:
Paul Osborne
2019-02-19 20:23:19 -08:00
committed by Carl Lerche
parent d0cdcff8aa
commit f513558076
+9
View File
@@ -74,6 +74,8 @@ use std::sync::atomic::Ordering::{Relaxed, SeqCst};
use std::sync::atomic::AtomicUsize;
use std::sync::{Arc, Weak};
use std::time::{Duration, Instant};
#[cfg(all(unix, not(target_os = "fuchsia")))]
use std::os::unix::io::{AsRawFd, RawFd};
use log::Level;
use mio::event::Evented;
@@ -429,6 +431,13 @@ impl Reactor {
}
}
#[cfg(all(unix, not(target_os = "fuchsia")))]
impl AsRawFd for Reactor {
fn as_raw_fd(&self) -> RawFd {
self.inner.io.as_raw_fd()
}
}
impl Park for Reactor {
type Unpark = Handle;
type Error = io::Error;