Skip to content

Commit a39473a

Browse files
committed
reactor AsyncPollable works with subscribe duration directly...
1 parent b44be3f commit a39473a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/runtime/polling.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ impl Poller {
7575
// to convert it back to the right keys for the wakers. Earlier we
7676
// established a positional index -> waker key relationship, so we can
7777
// go right ahead and perform a lookup there.
78-
ready_indexes
78+
dbg!(ready_indexes
7979
.into_iter()
8080
.map(|index| EventKey(indexes[index as usize] as u32))
81-
.collect()
81+
.collect())
8282
}
8383
}
8484

src/runtime/reactor.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ impl Reactor {
128128
for key in reactor.poller.block_until() {
129129
for (waitee, waker) in reactor.wakers.iter() {
130130
if waitee.pollable.0.key == key {
131+
println!("waking {key:?}");
131132
waker.wake_by_ref()
132133
}
133134
}
@@ -175,3 +176,17 @@ impl Reactor {
175176
p.wait_for().await
176177
}
177178
}
179+
180+
#[cfg(test)]
181+
mod test {
182+
use super::*;
183+
#[test]
184+
fn reactor_subscribe_duration() {
185+
crate::runtime::block_on(async {
186+
let reactor = Reactor::current();
187+
let pollable = wasi::clocks::monotonic_clock::subscribe_duration(1000);
188+
let sched = reactor.schedule(pollable);
189+
sched.wait_for().await;
190+
})
191+
}
192+
}

0 commit comments

Comments
 (0)