aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw/state_critical_section.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-executor/src/raw/state_critical_section.rs')
-rw-r--r--embassy-executor/src/raw/state_critical_section.rs25
1 files changed, 0 insertions, 25 deletions
diff --git a/embassy-executor/src/raw/state_critical_section.rs b/embassy-executor/src/raw/state_critical_section.rs
index 8e570b33c..29b10f6e3 100644
--- a/embassy-executor/src/raw/state_critical_section.rs
+++ b/embassy-executor/src/raw/state_critical_section.rs
@@ -3,14 +3,10 @@ use core::cell::Cell;
3pub(crate) use critical_section::{with as locked, CriticalSection as Token}; 3pub(crate) use critical_section::{with as locked, CriticalSection as Token};
4use critical_section::{CriticalSection, Mutex}; 4use critical_section::{CriticalSection, Mutex};
5 5
6use super::timer_queue::TimerEnqueueOperation;
7
8/// Task is spawned (has a future) 6/// Task is spawned (has a future)
9pub(crate) const STATE_SPAWNED: u32 = 1 << 0; 7pub(crate) const STATE_SPAWNED: u32 = 1 << 0;
10/// Task is in the executor run queue 8/// Task is in the executor run queue
11pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1; 9pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1;
12/// Task is in the executor timer queue
13pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2;
14 10
15pub(crate) struct State { 11pub(crate) struct State {
16 state: Mutex<Cell<u32>>, 12 state: Mutex<Cell<u32>>,
@@ -81,25 +77,4 @@ impl State {
81 ok 77 ok
82 }) 78 })
83 } 79 }
84
85 /// Mark the task as timer-queued. Return whether it can be enqueued.
86 #[inline(always)]
87 pub fn timer_enqueue(&self) -> TimerEnqueueOperation {
88 self.update(|s| {
89 // FIXME: we need to split SPAWNED into two phases, to prevent enqueueing a task that is
90 // just being spawned, because its executor pointer may still be changing.
91 if *s & STATE_SPAWNED == STATE_SPAWNED {
92 *s |= STATE_TIMER_QUEUED;
93 TimerEnqueueOperation::Enqueue
94 } else {
95 TimerEnqueueOperation::Ignore
96 }
97 })
98 }
99
100 /// Unmark the task as timer-queued.
101 #[inline(always)]
102 pub fn timer_dequeue(&self) {
103 self.update(|s| *s &= !STATE_TIMER_QUEUED);
104 }
105} 80}