tokio-reactor: impl AsRawFd for reactor for unix
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.
@@ -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;
