Skip to content

Commit

Permalink
Allow wake up the reactor on wasi
Browse files Browse the repository at this point in the history
Signed-off-by: csh <[email protected]>
  • Loading branch information
L-jasmine authored and CaptainVincent committed Dec 1, 2024
1 parent bc7e791 commit 9204f4c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tokio/src/runtime/io/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub(crate) struct Handle {

/// Used to wake up the reactor from a call to `turn`.
/// Not supported on `Wasi` due to lack of threading support.
#[cfg(not(target_os = "wasi"))]
#[cfg(not(all(target_os = "wasi", not(tokio_unstable))))]
waker: mio::Waker,

pub(crate) metrics: IoDriverMetrics,
Expand Down Expand Up @@ -93,7 +93,7 @@ impl Driver {
/// creation.
pub(crate) fn new(nevents: usize) -> io::Result<(Driver, Handle)> {
let poll = mio::Poll::new()?;
#[cfg(not(target_os = "wasi"))]
#[cfg(not(all(target_os = "wasi", not(tokio_unstable))))]
let waker = mio::Waker::new(poll.registry(), TOKEN_WAKEUP)?;
let registry = poll.registry().try_clone()?;

Expand All @@ -109,7 +109,7 @@ impl Driver {
registry,
registrations,
synced: Mutex::new(synced),
#[cfg(not(target_os = "wasi"))]
#[cfg(not(all(target_os = "wasi", not(tokio_unstable))))]
waker,
metrics: IoDriverMetrics::default(),
};
Expand Down Expand Up @@ -204,7 +204,7 @@ impl Handle {
/// blocked in `turn`, then the next call to `turn` will not block and
/// return immediately.
pub(crate) fn unpark(&self) {
#[cfg(not(target_os = "wasi"))]
#[cfg(not(all(target_os = "wasi", not(tokio_unstable))))]
self.waker.wake().expect("failed to wake I/O driver");
}

Expand Down

0 comments on commit 9204f4c

Please sign in to comment.