Skip to content

Commit

Permalink
Support for change to Mio
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Zak <richard@profian.com>
  • Loading branch information
rjzak committed Jun 3, 2022
1 parent 0f9dff3 commit 91de6f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
16 changes: 9 additions & 7 deletions tokio/src/io/driver/mod.rs
Expand Up @@ -71,10 +71,10 @@ pub(super) struct Inner {
resources: Mutex<Option<Slab<ScheduledIo>>>,

/// Registers I/O resources.
#[cfg(not(target_arch = "wasm32"))]
//#[cfg(not(target_arch = "wasm32"))]
registry: mio::Registry,
#[cfg(target_arch = "wasm32")]
registry: Arc<mio::Registry>,
//#[cfg(target_arch = "wasm32")]
//registry: Arc<mio::Registry>,

/// Allocates `ScheduledIo` handles when creating new resources.
pub(super) io_dispatch: slab::Allocator<ScheduledIo>,
Expand Down Expand Up @@ -127,10 +127,12 @@ impl Driver {
#[cfg(not(target_os = "wasi"))]
let waker = mio::Waker::new(poll.registry(), TOKEN_WAKEUP)?;

#[cfg(not(target_os = "wasi"))]
//#[cfg(not(target_os = "wasi"))]
let registry = poll.registry().try_clone()?;
#[cfg(target_os = "wasi")]
let registry = poll.registry();
//#[cfg(target_os = "wasi")]
//let registry = poll.registry();

// let registry = poll.registry().clone();

let slab = Slab::new();
let allocator = slab.allocator();
Expand All @@ -142,7 +144,7 @@ impl Driver {
resources: Some(slab),
inner: Arc::new(Inner {
resources: Mutex::new(None),
registry: registry,
registry,
io_dispatch: allocator,
#[cfg(not(target_os = "wasi"))]
waker,
Expand Down
3 changes: 0 additions & 3 deletions tokio/src/io/driver/registration.rs
Expand Up @@ -247,14 +247,11 @@ cfg_io_readiness! {
}

pub(crate) async fn async_io<R>(&self, interest: Interest, mut f: impl FnMut() -> io::Result<R>) -> io::Result<R> {
println!("Tokio Registration::async_io() {}:{}", file!(), line!());
loop {
let event = self.readiness(interest).await?;
println!("Tokio Registration::async_io() self.readiness({:?}) = {:?} returned @ {}:{}", interest, event, file!(), line!());
match f() {
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
self.clear_readiness(event);
println!("Tokio Registration::async_io() self.clear_readiness() {}:{}", file!(), line!());
}
x => return x,
}
Expand Down

0 comments on commit 91de6f2

Please sign in to comment.