diff options
Diffstat (limited to 'embassy-executor')
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/raw/state_atomics.rs | 10 | ||||
| -rw-r--r-- | embassy-executor/src/raw/state_critical_section.rs | 10 |
3 files changed, 11 insertions, 11 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index e7a27035a..913da2e25 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #[cfg_attr(not(target_has_atomic = "ptr"), path = "run_queue_critical_section.rs")] | 11 | #[cfg_attr(not(target_has_atomic = "ptr"), path = "run_queue_critical_section.rs")] |
| 12 | mod run_queue; | 12 | mod run_queue; |
| 13 | 13 | ||
| 14 | #[cfg_attr(all(cortex_m, target_has_atomic = "8"), path = "state_atomics_arm.rs")] | 14 | #[cfg_attr(all(cortex_m, target_has_atomic = "32"), path = "state_atomics_arm.rs")] |
| 15 | #[cfg_attr(all(not(cortex_m), target_has_atomic = "8"), path = "state_atomics.rs")] | 15 | #[cfg_attr(all(not(cortex_m), target_has_atomic = "8"), path = "state_atomics.rs")] |
| 16 | #[cfg_attr(not(target_has_atomic = "8"), path = "state_critical_section.rs")] | 16 | #[cfg_attr(not(target_has_atomic = "8"), path = "state_critical_section.rs")] |
| 17 | mod state; | 17 | mod state; |
diff --git a/embassy-executor/src/raw/state_atomics.rs b/embassy-executor/src/raw/state_atomics.rs index b6576bfc2..e813548ae 100644 --- a/embassy-executor/src/raw/state_atomics.rs +++ b/embassy-executor/src/raw/state_atomics.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use core::sync::atomic::{AtomicU32, Ordering}; | 1 | use core::sync::atomic::{AtomicU8, Ordering}; |
| 2 | 2 | ||
| 3 | #[derive(Clone, Copy)] | 3 | #[derive(Clone, Copy)] |
| 4 | pub(crate) struct Token(()); | 4 | pub(crate) struct Token(()); |
| @@ -11,18 +11,18 @@ pub(crate) fn locked<R>(f: impl FnOnce(Token) -> R) -> R { | |||
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | /// Task is spawned (has a future) | 13 | /// Task is spawned (has a future) |
| 14 | pub(crate) const STATE_SPAWNED: u32 = 1 << 0; | 14 | pub(crate) const STATE_SPAWNED: u8 = 1 << 0; |
| 15 | /// Task is in the executor run queue | 15 | /// Task is in the executor run queue |
| 16 | pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1; | 16 | pub(crate) const STATE_RUN_QUEUED: u8 = 1 << 1; |
| 17 | 17 | ||
| 18 | pub(crate) struct State { | 18 | pub(crate) struct State { |
| 19 | state: AtomicU32, | 19 | state: AtomicU8, |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | impl State { | 22 | impl State { |
| 23 | pub const fn new() -> State { | 23 | pub const fn new() -> State { |
| 24 | Self { | 24 | Self { |
| 25 | state: AtomicU32::new(0), | 25 | state: AtomicU8::new(0), |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
| 28 | 28 | ||
diff --git a/embassy-executor/src/raw/state_critical_section.rs b/embassy-executor/src/raw/state_critical_section.rs index 6b627ff79..ec08f2f58 100644 --- a/embassy-executor/src/raw/state_critical_section.rs +++ b/embassy-executor/src/raw/state_critical_section.rs | |||
| @@ -4,12 +4,12 @@ pub(crate) use critical_section::{with as locked, CriticalSection as Token}; | |||
| 4 | use critical_section::{CriticalSection, Mutex}; | 4 | use critical_section::{CriticalSection, Mutex}; |
| 5 | 5 | ||
| 6 | /// Task is spawned (has a future) | 6 | /// Task is spawned (has a future) |
| 7 | pub(crate) const STATE_SPAWNED: u32 = 1 << 0; | 7 | pub(crate) const STATE_SPAWNED: u8 = 1 << 0; |
| 8 | /// Task is in the executor run queue | 8 | /// Task is in the executor run queue |
| 9 | pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1; | 9 | pub(crate) const STATE_RUN_QUEUED: u8 = 1 << 1; |
| 10 | 10 | ||
| 11 | pub(crate) struct State { | 11 | pub(crate) struct State { |
| 12 | state: Mutex<Cell<u32>>, | 12 | state: Mutex<Cell<u8>>, |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | impl State { | 15 | impl State { |
| @@ -19,11 +19,11 @@ impl State { | |||
| 19 | } | 19 | } |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | fn update<R>(&self, f: impl FnOnce(&mut u32) -> R) -> R { | 22 | fn update<R>(&self, f: impl FnOnce(&mut u8) -> R) -> R { |
| 23 | critical_section::with(|cs| self.update_with_cs(cs, f)) | 23 | critical_section::with(|cs| self.update_with_cs(cs, f)) |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | fn update_with_cs<R>(&self, cs: CriticalSection<'_>, f: impl FnOnce(&mut u32) -> R) -> R { | 26 | fn update_with_cs<R>(&self, cs: CriticalSection<'_>, f: impl FnOnce(&mut u8) -> R) -> R { |
| 27 | let s = self.state.borrow(cs); | 27 | let s = self.state.borrow(cs); |
| 28 | let mut val = s.get(); | 28 | let mut val = s.get(); |
| 29 | let r = f(&mut val); | 29 | let r = f(&mut val); |
