Remove special handling of integrated timer queue

This commit is contained in:
Dániel Buga
2024-12-16 18:08:19 +01:00
parent d3f0294fb1
commit 3c121e5425
5 changed files with 13 additions and 57 deletions

View File

@@ -195,25 +195,7 @@ impl<F: Future + 'static> TaskStorage<F> {
match future.poll(&mut cx) {
Poll::Ready(_) => {
this.future.drop_in_place();
// Mark this task to be timer queued.
// We're splitting the enqueue in two parts, so that we can change task state
// to something that prevent re-queueing.
let op = this.raw.state.timer_enqueue();
// Now mark the task as not spawned, so that
// - it can be spawned again once it has been removed from the timer queue
// - it can not be timer-queued again
// We must do this before scheduling the wake, to prevent the task from being
// dequeued by the time driver while it's still SPAWNED.
this.raw.state.despawn();
// Now let's finish enqueueing. While we shouldn't get an `Ignore` here, it's
// better to be safe.
if op == timer_queue::TimerEnqueueOperation::Enqueue {
// Schedule the task in the past, so it gets dequeued ASAP.
unsafe { _embassy_time_schedule_wake(0, &waker) }
}
}
Poll::Pending => {}
}
@@ -232,10 +214,6 @@ impl<F: Future + 'static> TaskStorage<F> {
}
}
extern "Rust" {
fn _embassy_time_schedule_wake(at: u64, waker: &core::task::Waker);
}
/// An uninitialized [`TaskStorage`].
pub struct AvailableTask<F: Future + 'static> {
task: &'static TaskStorage<F>,