diff options
Diffstat (limited to 'embassy-time-queue-driver/src/lib.rs')
| -rw-r--r-- | embassy-time-queue-driver/src/lib.rs | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/embassy-time-queue-driver/src/lib.rs b/embassy-time-queue-driver/src/lib.rs index 97c81a124..333b6124d 100644 --- a/embassy-time-queue-driver/src/lib.rs +++ b/embassy-time-queue-driver/src/lib.rs | |||
| @@ -10,8 +10,6 @@ | |||
| 10 | //! As a HAL implementer, you need to depend on this crate if you want to implement a time driver, | 10 | //! As a HAL implementer, you need to depend on this crate if you want to implement a time driver, |
| 11 | //! but how you should do so is documented in `embassy-time-driver`. | 11 | //! but how you should do so is documented in `embassy-time-driver`. |
| 12 | 12 | ||
| 13 | use core::task::Waker; | ||
| 14 | |||
| 15 | #[cfg(feature = "_generic-queue")] | 13 | #[cfg(feature = "_generic-queue")] |
| 16 | pub mod queue_generic; | 14 | pub mod queue_generic; |
| 17 | #[cfg(not(feature = "_generic-queue"))] | 15 | #[cfg(not(feature = "_generic-queue"))] |
| @@ -21,29 +19,3 @@ pub mod queue_integrated; | |||
| 21 | pub use queue_generic::Queue; | 19 | pub use queue_generic::Queue; |
| 22 | #[cfg(not(feature = "_generic-queue"))] | 20 | #[cfg(not(feature = "_generic-queue"))] |
| 23 | pub use queue_integrated::Queue; | 21 | pub use queue_integrated::Queue; |
| 24 | |||
| 25 | extern "Rust" { | ||
| 26 | fn _embassy_time_schedule_wake(at: u64, waker: &Waker); | ||
| 27 | } | ||
| 28 | |||
| 29 | /// Schedule the given waker to be woken at `at`. | ||
| 30 | pub fn schedule_wake(at: u64, waker: &Waker) { | ||
| 31 | // This function is not implemented in embassy-time-driver because it needs access to executor | ||
| 32 | // internals. The function updates task state, then delegates to the implementation provided | ||
| 33 | // by the time driver. | ||
| 34 | #[cfg(not(feature = "_generic-queue"))] | ||
| 35 | { | ||
| 36 | use embassy_executor::raw::task_from_waker; | ||
| 37 | use embassy_executor::raw::timer_queue::TimerEnqueueOperation; | ||
| 38 | // The very first thing we must do, before we even access the timer queue, is to | ||
| 39 | // mark the task a TIMER_QUEUED. This ensures that the task that is being scheduled | ||
| 40 | // can not be respawn while we are accessing the timer queue. | ||
| 41 | let task = task_from_waker(waker); | ||
| 42 | if unsafe { task.timer_enqueue() } == TimerEnqueueOperation::Ignore { | ||
| 43 | // We are not allowed to enqueue the task in the timer queue. This is because the | ||
| 44 | // task is not spawned, and so it makes no sense to schedule it. | ||
| 45 | return; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | unsafe { _embassy_time_schedule_wake(at, waker) } | ||
| 49 | } | ||
