diff options
| author | Dániel Buga <[email protected]> | 2024-12-09 08:43:57 +0100 |
|---|---|---|
| committer | Dániel Buga <[email protected]> | 2024-12-13 21:20:57 +0100 |
| commit | ec96395d084d5edc8be25ddaea8547e2ebd447a6 (patch) | |
| tree | b1edf825c8d67013df3cec1283376a7558951a3f /embassy-executor/src/raw/timer_queue.rs | |
| parent | d45ea43892198484b5f6dcea4c351dc11d226cc4 (diff) | |
Prevent task from respawning while in the timer queue
Diffstat (limited to 'embassy-executor/src/raw/timer_queue.rs')
| -rw-r--r-- | embassy-executor/src/raw/timer_queue.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/embassy-executor/src/raw/timer_queue.rs b/embassy-executor/src/raw/timer_queue.rs index 46e346c1b..c36708401 100644 --- a/embassy-executor/src/raw/timer_queue.rs +++ b/embassy-executor/src/raw/timer_queue.rs | |||
| @@ -7,6 +7,9 @@ use super::TaskRef; | |||
| 7 | /// An item in the timer queue. | 7 | /// An item in the timer queue. |
| 8 | pub struct TimerQueueItem { | 8 | pub struct TimerQueueItem { |
| 9 | /// The next item in the queue. | 9 | /// The next item in the queue. |
| 10 | /// | ||
| 11 | /// If this field contains `Some`, the item is in the queue. The last item in the queue has a | ||
| 12 | /// value of `Some(dangling_pointer)` | ||
| 10 | pub next: Cell<Option<TaskRef>>, | 13 | pub next: Cell<Option<TaskRef>>, |
| 11 | 14 | ||
| 12 | /// The time at which this item expires. | 15 | /// The time at which this item expires. |
| @@ -19,7 +22,17 @@ impl TimerQueueItem { | |||
| 19 | pub(crate) const fn new() -> Self { | 22 | pub(crate) const fn new() -> Self { |
| 20 | Self { | 23 | Self { |
| 21 | next: Cell::new(None), | 24 | next: Cell::new(None), |
| 22 | expires_at: Cell::new(0), | 25 | expires_at: Cell::new(u64::MAX), |
| 23 | } | 26 | } |
| 24 | } | 27 | } |
| 25 | } | 28 | } |
| 29 | |||
| 30 | /// The operation to perform after `timer_enqueue` is called. | ||
| 31 | #[derive(Debug, Copy, Clone, PartialEq)] | ||
| 32 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 33 | pub enum TimerEnqueueOperation { | ||
| 34 | /// Enqueue the task. | ||
| 35 | Enqueue, | ||
| 36 | /// Update the task's expiration time. | ||
| 37 | Ignore, | ||
| 38 | } | ||
