diff options
| author | Dániel Buga <[email protected]> | 2024-12-16 19:03:00 +0100 |
|---|---|---|
| committer | Dániel Buga <[email protected]> | 2024-12-16 20:37:02 +0100 |
| commit | c90d048ecb611908f5696b4f57d689bdb254aee6 (patch) | |
| tree | 9800ad14610b683b0d5048f89e84a3d835822171 /embassy-executor/src/raw/state_atomics_arm.rs | |
| parent | a8617429e4c3177a3e7c31b20ee36a2dfe6b6430 (diff) | |
Remove TIMER_QUEUED
Diffstat (limited to 'embassy-executor/src/raw/state_atomics_arm.rs')
| -rw-r--r-- | embassy-executor/src/raw/state_atomics_arm.rs | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/embassy-executor/src/raw/state_atomics_arm.rs b/embassy-executor/src/raw/state_atomics_arm.rs index c1e8f69ab..4896b33c5 100644 --- a/embassy-executor/src/raw/state_atomics_arm.rs +++ b/embassy-executor/src/raw/state_atomics_arm.rs | |||
| @@ -1,8 +1,6 @@ | |||
| 1 | use core::arch::asm; | 1 | use core::arch::asm; |
| 2 | use core::sync::atomic::{compiler_fence, AtomicBool, AtomicU32, Ordering}; | 2 | use core::sync::atomic::{compiler_fence, AtomicBool, AtomicU32, Ordering}; |
| 3 | 3 | ||
| 4 | use super::timer_queue::TimerEnqueueOperation; | ||
| 5 | |||
| 6 | #[derive(Clone, Copy)] | 4 | #[derive(Clone, Copy)] |
| 7 | pub(crate) struct Token(()); | 5 | pub(crate) struct Token(()); |
| 8 | 6 | ||
| @@ -16,7 +14,6 @@ pub(crate) fn locked<R>(f: impl FnOnce(Token) -> R) -> R { | |||
| 16 | // Must be kept in sync with the layout of `State`! | 14 | // Must be kept in sync with the layout of `State`! |
| 17 | pub(crate) const STATE_SPAWNED: u32 = 1 << 0; | 15 | pub(crate) const STATE_SPAWNED: u32 = 1 << 0; |
| 18 | pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 8; | 16 | pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 8; |
| 19 | pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 16; | ||
| 20 | 17 | ||
| 21 | #[repr(C, align(4))] | 18 | #[repr(C, align(4))] |
| 22 | pub(crate) struct State { | 19 | pub(crate) struct State { |
| @@ -24,9 +21,8 @@ pub(crate) struct State { | |||
| 24 | spawned: AtomicBool, | 21 | spawned: AtomicBool, |
| 25 | /// Task is in the executor run queue | 22 | /// Task is in the executor run queue |
| 26 | run_queued: AtomicBool, | 23 | run_queued: AtomicBool, |
| 27 | /// Task is in the executor timer queue | ||
| 28 | timer_queued: AtomicBool, | ||
| 29 | pad: AtomicBool, | 24 | pad: AtomicBool, |
| 25 | pad2: AtomicBool, | ||
| 30 | } | 26 | } |
| 31 | 27 | ||
| 32 | impl State { | 28 | impl State { |
| @@ -34,8 +30,8 @@ impl State { | |||
| 34 | Self { | 30 | Self { |
| 35 | spawned: AtomicBool::new(false), | 31 | spawned: AtomicBool::new(false), |
| 36 | run_queued: AtomicBool::new(false), | 32 | run_queued: AtomicBool::new(false), |
| 37 | timer_queued: AtomicBool::new(false), | ||
| 38 | pad: AtomicBool::new(false), | 33 | pad: AtomicBool::new(false), |
| 34 | pad2: AtomicBool::new(false), | ||
| 39 | } | 35 | } |
| 40 | } | 36 | } |
| 41 | 37 | ||
| @@ -101,32 +97,4 @@ impl State { | |||
| 101 | self.run_queued.store(false, Ordering::Relaxed); | 97 | self.run_queued.store(false, Ordering::Relaxed); |
| 102 | r | 98 | r |
| 103 | } | 99 | } |
| 104 | |||
| 105 | /// Mark the task as timer-queued. Return whether it can be enqueued. | ||
| 106 | #[inline(always)] | ||
| 107 | pub fn timer_enqueue(&self) -> TimerEnqueueOperation { | ||
| 108 | if self | ||
| 109 | .as_u32() | ||
| 110 | .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |state| { | ||
| 111 | // If not started, ignore it | ||
| 112 | if state & STATE_SPAWNED == 0 { | ||
| 113 | None | ||
| 114 | } else { | ||
| 115 | // Mark it as enqueued | ||
| 116 | Some(state | STATE_TIMER_QUEUED) | ||
| 117 | } | ||
| 118 | }) | ||
| 119 | .is_ok() | ||
| 120 | { | ||
| 121 | TimerEnqueueOperation::Enqueue | ||
| 122 | } else { | ||
| 123 | TimerEnqueueOperation::Ignore | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | /// Unmark the task as timer-queued. | ||
| 128 | #[inline(always)] | ||
| 129 | pub fn timer_dequeue(&self) { | ||
| 130 | self.timer_queued.store(false, Ordering::Relaxed); | ||
| 131 | } | ||
| 132 | } | 100 | } |
