diff options
author | Jon Gjengset <jon@thesquareplanet.com> | 2020-02-12 14:09:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-12 11:09:44 -0800 |
commit | c1232a65207e3b2d42d82b9144658f6293287089 (patch) | |
tree | 883579843c03175e28526bfaba09d429d0b8a098 /tokio/src/io | |
parent | 5e75b0446d771f527d65ecc7ba34e2276eb2bf21 (diff) |
io: avoid unnecessary wake in registration (#2221)
See discussion in #2222. This wake/notify call has been there in one
form or another since the very early days of tokio. Currently though, it
is not clear that it is needed; the contract for polling is that you
must keep polling until you get `Pending`, so doing a wakeup when we are
about to return `Ready` is premature.
Diffstat (limited to 'tokio/src/io')
-rw-r--r-- | tokio/src/io/driver/mod.rs | 14 | ||||
-rw-r--r-- | tokio/src/io/driver/scheduled_io.rs | 1 |
2 files changed, 4 insertions, 11 deletions
diff --git a/tokio/src/io/driver/mod.rs b/tokio/src/io/driver/mod.rs index 8385448c..e707d3a5 100644 --- a/tokio/src/io/driver/mod.rs +++ b/tokio/src/io/driver/mod.rs @@ -277,20 +277,12 @@ impl Inner { .get(token) .unwrap_or_else(|| panic!("IO resource for token {:?} does not exist!", token)); - let readiness = sched - .get_readiness(token) - .unwrap_or_else(|| panic!("token {:?} no longer valid!", token)); - - let (waker, ready) = match dir { - Direction::Read => (&sched.reader, !mio::Ready::writable()), - Direction::Write => (&sched.writer, mio::Ready::writable()), + let waker = match dir { + Direction::Read => &sched.reader, + Direction::Write => &sched.writer, }; waker.register(w); - - if readiness & ready.as_usize() != 0 { - waker.wake(); - } } } diff --git a/tokio/src/io/driver/scheduled_io.rs b/tokio/src/io/driver/scheduled_io.rs index e26a3588..7f6446e3 100644 --- a/tokio/src/io/driver/scheduled_io.rs +++ b/tokio/src/io/driver/scheduled_io.rs @@ -56,6 +56,7 @@ impl Default for ScheduledIo { } impl ScheduledIo { + #[cfg(all(test, loom))] /// Returns the current readiness value of this `ScheduledIo`, if the /// provided `token` is still a valid access. /// |