diff options
Diffstat (limited to 'embassy-time-queue-driver/src/lib.rs')
| -rw-r--r-- | embassy-time-queue-driver/src/lib.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/embassy-time-queue-driver/src/lib.rs b/embassy-time-queue-driver/src/lib.rs index 0c78921ed..2d5fd449a 100644 --- a/embassy-time-queue-driver/src/lib.rs +++ b/embassy-time-queue-driver/src/lib.rs | |||
| @@ -73,6 +73,20 @@ extern "Rust" { | |||
| 73 | 73 | ||
| 74 | /// Schedule the given waker to be woken at `at`. | 74 | /// Schedule the given waker to be woken at `at`. |
| 75 | pub fn schedule_wake(at: u64, waker: &Waker) { | 75 | pub fn schedule_wake(at: u64, waker: &Waker) { |
| 76 | #[cfg(feature = "integrated-timers")] | ||
| 77 | { | ||
| 78 | use embassy_executor::raw::task_from_waker; | ||
| 79 | use embassy_executor::raw::timer_queue::TimerEnqueueOperation; | ||
| 80 | // The very first thing we must do, before we even access the timer queue, is to | ||
| 81 | // mark the task a TIMER_QUEUED. This ensures that the task that is being scheduled | ||
| 82 | // can not be respawn while we are accessing the timer queue. | ||
| 83 | let task = task_from_waker(waker); | ||
| 84 | if unsafe { task.timer_enqueue() } == TimerEnqueueOperation::Ignore { | ||
| 85 | // We are not allowed to enqueue the task in the timer queue. This is because the | ||
| 86 | // task is not spawned, and so it makes no sense to schedule it. | ||
| 87 | return; | ||
| 88 | } | ||
| 89 | } | ||
| 76 | unsafe { _embassy_time_schedule_wake(at, waker) } | 90 | unsafe { _embassy_time_schedule_wake(at, waker) } |
| 77 | } | 91 | } |
| 78 | 92 | ||
