master
ondra05 2022-11-05 01:43:41 +01:00
parent 444bbb7bd1
commit 67510d7ae9
1 changed files with 6 additions and 11 deletions

View File

@ -91,11 +91,12 @@ impl Executor {
panic!("attempted to get non-extant task with id {}", id.0) panic!("attempted to get non-extant task with id {}", id.0)
}; };
let mut cx = Context::from_waker( let mut cx = Context::from_waker(self.wakers.entry(id).or_insert_with(|| {
self.wakers Waker::from(Arc::new(TaskWaker {
.entry(id) id,
.or_insert_with(|| TaskWaker::new(id, Arc::clone(&self.queue))), queue: Arc::clone(&self.queue),
); }))
}));
match task.poll(&mut cx) { match task.poll(&mut cx) {
Poll::Ready(()) => { Poll::Ready(()) => {
@ -137,12 +138,6 @@ struct TaskWaker {
queue: TaskQueue, queue: TaskQueue,
} }
impl TaskWaker {
fn new(id: TaskId, queue: TaskQueue) -> Waker {
Waker::from(Arc::new(Self { id, queue }))
}
}
impl Wake for TaskWaker { impl Wake for TaskWaker {
fn wake(self: Arc<Self>) { fn wake(self: Arc<Self>) {
self.wake_by_ref(); self.wake_by_ref();