Skip to content

Commit f6ebc91

Browse files
Add waker functionality
- Forgot to add task wakers in futures
1 parent 90bee1d commit f6ebc91

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

src/engine.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ impl WasmRuntimeAsyncEngine {
7575
}
7676
}
7777

78+
79+
pub fn next_id()
80+
{
81+
82+
}
7883
struct FutureWaker(Sender<()>);
7984

8085
impl FutureWaker {
@@ -91,7 +96,7 @@ impl Wake for FutureWaker {
9196

9297
#[cfg(test)]
9398
mod test {
94-
99+
95100
use super::*;
96101
use std::future::Future;
97102

src/io/net.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<'a> Future for ConnectionFuture<'a> {
155155
type Output = IOResult<()>;
156156
fn poll(
157157
self: std::pin::Pin<&mut Self>,
158-
_: &mut std::task::Context<'_>,
158+
cx: &mut std::task::Context<'_>,
159159
) -> std::task::Poll<Self::Output> {
160160
let this = self.get_mut();
161161
if !REACTOR.lock().unwrap().is_pollable(&this.async_key) {
@@ -172,6 +172,7 @@ impl<'a> Future for ConnectionFuture<'a> {
172172
this.stream.finish_connecting()?;
173173
Poll::Ready(Ok(()))
174174
} else {
175+
cx.waker().wake_by_ref();
175176
Poll::Pending
176177
}
177178
}

src/io/timer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl Future for TimeoutFuture {
5555
type Output = ();
5656
fn poll(
5757
self: std::pin::Pin<&mut Self>,
58-
_: &mut std::task::Context<'_>,
58+
cx: &mut std::task::Context<'_>,
5959
) -> std::task::Poll<Self::Output> {
6060
let has_elapsed = TIMERS
6161
.get(&self.id)
@@ -64,6 +64,7 @@ impl Future for TimeoutFuture {
6464
if has_elapsed {
6565
return std::task::Poll::Ready(());
6666
}
67+
cx.waker().wake_by_ref();
6768
std::task::Poll::Pending
6869
}
6970
}

src/poll_tasks.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use std::{
2-
collections::HashMap,
3-
sync::Arc,
4-
};
1+
use std::{collections::HashMap, sync::Arc};
52

63
use crate::bindings::wasi::io::poll::{poll, Pollable};
74

@@ -49,4 +46,3 @@ impl PollTasks {
4946
}
5047
}
5148
}
52-

0 commit comments

Comments
 (0)