Skip to content

Commit

Permalink
add special waker for priority events
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Apr 20, 2023
1 parent 7a8991f commit fc0b2af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tokio/src/io/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl Ready {
/// ```
#[cfg(any(target_os = "linux", target_os = "android"))]
#[cfg_attr(docsrs, doc(cfg(any(target_os = "linux", target_os = "android"))))]
pub fn is_priority(self) -> bool {
pub fn is_priority_ready(self) -> bool {
self.contains(Ready::PRIORITY)
}

Expand Down Expand Up @@ -289,7 +289,7 @@ impl fmt::Debug for Ready {
.field("is_writable", &self.is_writable())
.field("is_read_closed", &self.is_read_closed())
.field("is_write_closed", &self.is_write_closed())
.field("is_priority", &self.is_priority())
.field("is_priority_ready", &self.is_priority_ready())
.finish()
}

Expand Down
11 changes: 11 additions & 0 deletions tokio/src/runtime/io/scheduled_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ struct Waiters {

/// Waker used for AsyncWrite.
writer: Option<Waker>,

/// Waker used for Priority
priority: Option<Waker>,
}

cfg_io_readiness! {
Expand Down Expand Up @@ -238,6 +241,14 @@ impl ScheduledIo {
}
}

// check for AsyncWrite slot
#[cfg(any(target_os = "linux", target_os = "android"))]
if ready.is_priority_ready() {
if let Some(waker) = waiters.priority.take() {
wakers.push(waker);
}
}

#[cfg(feature = "net")]
'outer: loop {
let mut iter = waiters.list.drain_filter(|w| ready.satisfies(w.interest));
Expand Down

0 comments on commit fc0b2af

Please sign in to comment.