diff options
author | Carl Lerche <me@carllerche.com> | 2020-11-11 09:28:21 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-11 09:28:21 -0800 |
commit | ce891a4df17e632f7557dd0cd1f1e8da89bd6ae4 (patch) | |
tree | fa5478c0b3bacacfc65bfbadbe1cdb92234d5b5f /tokio/src/io/driver/mod.rs | |
parent | d869e16990c5fc2cbda48b036708efa4b450e807 (diff) |
io: driver internal cleanup (#3124)
* Removes duplicated code by moving it to `Registration`.
* impl `Deref` for `PollEvented` to avoid `get_ref()`.
* Avoid extra waker clones in I/O driver.
* Add `Interest` wrapper around `mio::Interest`.
Diffstat (limited to 'tokio/src/io/driver/mod.rs')
-rw-r--r-- | tokio/src/io/driver/mod.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tokio/src/io/driver/mod.rs b/tokio/src/io/driver/mod.rs index a7d4b7b8..c494db41 100644 --- a/tokio/src/io/driver/mod.rs +++ b/tokio/src/io/driver/mod.rs @@ -1,10 +1,16 @@ #![cfg_attr(not(feature = "rt"), allow(dead_code))] +mod interest; +pub(crate) use interest::Interest; + mod ready; use ready::Ready; +mod registration; +pub(crate) use registration::Registration; + mod scheduled_io; -pub(crate) use scheduled_io::ScheduledIo; // pub(crate) for tests +use scheduled_io::ScheduledIo; use crate::park::{Park, Unpark}; use crate::util::slab::{self, Slab}; @@ -68,7 +74,7 @@ pub(super) struct Inner { } #[derive(Debug, Eq, PartialEq, Clone, Copy)] -pub(super) enum Direction { +enum Direction { Read, Write, } @@ -313,7 +319,7 @@ impl Inner { pub(super) fn add_source( &self, source: &mut impl mio::event::Source, - interest: mio::Interest, + interest: Interest, ) -> io::Result<slab::Ref<ScheduledIo>> { let (address, shared) = self.io_dispatch.allocate().ok_or_else(|| { io::Error::new( @@ -325,7 +331,7 @@ impl Inner { let token = GENERATION.pack(shared.generation(), ADDRESS.pack(address.as_usize(), 0)); self.registry - .register(source, mio::Token(token), interest)?; + .register(source, mio::Token(token), interest.to_mio())?; Ok(shared) } |