diff options
Diffstat (limited to 'embassy-time-queue-driver/src/queue_integrated.rs')
| -rw-r--r-- | embassy-time-queue-driver/src/queue_integrated.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/embassy-time-queue-driver/src/queue_integrated.rs b/embassy-time-queue-driver/src/queue_integrated.rs index b905c00c3..6bb4c0c1a 100644 --- a/embassy-time-queue-driver/src/queue_integrated.rs +++ b/embassy-time-queue-driver/src/queue_integrated.rs | |||
| @@ -1,15 +1,16 @@ | |||
| 1 | //! Timer queue operations. | 1 | //! Timer queue operations. |
| 2 | use core::cell::Cell; | 2 | use core::cell::Cell; |
| 3 | use core::cmp::min; | 3 | use core::cmp::min; |
| 4 | use core::task::Waker; | ||
| 4 | 5 | ||
| 5 | use embassy_executor::raw::TaskRef; | 6 | use embassy_executor::raw::TaskRef; |
| 6 | 7 | ||
| 7 | /// A timer queue, with items integrated into tasks. | 8 | /// A timer queue, with items integrated into tasks. |
| 8 | pub struct TimerQueue { | 9 | pub struct Queue { |
| 9 | head: Cell<Option<TaskRef>>, | 10 | head: Cell<Option<TaskRef>>, |
| 10 | } | 11 | } |
| 11 | 12 | ||
| 12 | impl TimerQueue { | 13 | impl Queue { |
| 13 | /// Creates a new timer queue. | 14 | /// Creates a new timer queue. |
| 14 | pub const fn new() -> Self { | 15 | pub const fn new() -> Self { |
| 15 | Self { head: Cell::new(None) } | 16 | Self { head: Cell::new(None) } |
| @@ -19,11 +20,12 @@ impl TimerQueue { | |||
| 19 | /// | 20 | /// |
| 20 | /// If this function returns `true`, the called should find the next expiration time and set | 21 | /// If this function returns `true`, the called should find the next expiration time and set |
| 21 | /// a new alarm for that time. | 22 | /// a new alarm for that time. |
| 22 | pub fn schedule_wake(&mut self, at: u64, p: TaskRef) -> bool { | 23 | pub fn schedule_wake(&mut self, at: u64, waker: &Waker) -> bool { |
| 23 | let item = p.timer_queue_item(); | 24 | let task = embassy_executor::raw::task_from_waker(waker); |
| 25 | let item = task.timer_queue_item(); | ||
| 24 | if item.next.get().is_none() { | 26 | if item.next.get().is_none() { |
| 25 | // If not in the queue, add it and update. | 27 | // If not in the queue, add it and update. |
| 26 | let prev = self.head.replace(Some(p)); | 28 | let prev = self.head.replace(Some(task)); |
| 27 | item.next.set(if prev.is_none() { | 29 | item.next.set(if prev.is_none() { |
| 28 | Some(unsafe { TaskRef::dangling() }) | 30 | Some(unsafe { TaskRef::dangling() }) |
| 29 | } else { | 31 | } else { |
