diff options
Diffstat (limited to 'embassy-executor')
| -rw-r--r-- | embassy-executor/Cargo.toml | 7 | ||||
| -rw-r--r-- | embassy-executor/src/arch/cortex_m.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/arch/riscv32.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/arch/std.rs | 3 | ||||
| -rw-r--r-- | embassy-executor/src/arch/wasm.rs | 3 | ||||
| -rw-r--r-- | embassy-executor/src/arch/xtensa.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 7 | ||||
| -rw-r--r-- | embassy-executor/src/thread.rs | 13 |
8 files changed, 5 insertions, 34 deletions
diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index 182dd6937..ce5e2741f 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml | |||
| @@ -31,11 +31,11 @@ features = ["nightly", "defmt", "pender-callback", "arch-cortex-m", "executor-th | |||
| 31 | 31 | ||
| 32 | # Architecture | 32 | # Architecture |
| 33 | _arch = [] # some arch was picked | 33 | _arch = [] # some arch was picked |
| 34 | arch-std = ["_arch", "critical-section/std", "thread-context"] | 34 | arch-std = ["_arch", "critical-section/std"] |
| 35 | arch-cortex-m = ["_arch", "dep:cortex-m"] | 35 | arch-cortex-m = ["_arch", "dep:cortex-m"] |
| 36 | arch-xtensa = ["_arch"] | 36 | arch-xtensa = ["_arch"] |
| 37 | arch-riscv32 = ["_arch"] | 37 | arch-riscv32 = ["_arch"] |
| 38 | arch-wasm = ["_arch", "dep:wasm-bindgen", "dep:js-sys", "thread-context"] | 38 | arch-wasm = ["_arch", "dep:wasm-bindgen", "dep:js-sys"] |
| 39 | 39 | ||
| 40 | # Enable creating a `Pender` from an arbitrary function pointer callback. | 40 | # Enable creating a `Pender` from an arbitrary function pointer callback. |
| 41 | pender-callback = [] | 41 | pender-callback = [] |
| @@ -45,9 +45,6 @@ executor-thread = [] | |||
| 45 | # Enable the interrupt-mode executor (available in Cortex-M only) | 45 | # Enable the interrupt-mode executor (available in Cortex-M only) |
| 46 | executor-interrupt = [] | 46 | executor-interrupt = [] |
| 47 | 47 | ||
| 48 | # Pass a context to the thread-mode executor. | ||
| 49 | thread-context = [] | ||
| 50 | |||
| 51 | # Enable nightly-only features | 48 | # Enable nightly-only features |
| 52 | nightly = [] | 49 | nightly = [] |
| 53 | 50 | ||
diff --git a/embassy-executor/src/arch/cortex_m.rs b/embassy-executor/src/arch/cortex_m.rs index 6c1300ae5..a29e5b23e 100644 --- a/embassy-executor/src/arch/cortex_m.rs +++ b/embassy-executor/src/arch/cortex_m.rs | |||
| @@ -21,9 +21,7 @@ mod thread { | |||
| 21 | pub struct Context; | 21 | pub struct Context; |
| 22 | 22 | ||
| 23 | impl ThreadContext for Context { | 23 | impl ThreadContext for Context { |
| 24 | #[cfg(feature = "thread-context")] | ||
| 25 | fn context(&self) -> OpaqueThreadContext { | 24 | fn context(&self) -> OpaqueThreadContext { |
| 26 | // Enabling thread-context is not incorrect, just wasteful. | ||
| 27 | OpaqueThreadContext(0) | 25 | OpaqueThreadContext(0) |
| 28 | } | 26 | } |
| 29 | 27 | ||
diff --git a/embassy-executor/src/arch/riscv32.rs b/embassy-executor/src/arch/riscv32.rs index 087204006..976e7bcb3 100644 --- a/embassy-executor/src/arch/riscv32.rs +++ b/embassy-executor/src/arch/riscv32.rs | |||
| @@ -27,9 +27,7 @@ mod thread { | |||
| 27 | pub struct Context; | 27 | pub struct Context; |
| 28 | 28 | ||
| 29 | impl ThreadContext for Context { | 29 | impl ThreadContext for Context { |
| 30 | #[cfg(feature = "thread-context")] | ||
| 31 | fn context(&self) -> OpaqueThreadContext { | 30 | fn context(&self) -> OpaqueThreadContext { |
| 32 | // Enabling thread-context is not incorrect, just wasteful. | ||
| 33 | OpaqueThreadContext(0) | 31 | OpaqueThreadContext(0) |
| 34 | } | 32 | } |
| 35 | 33 | ||
diff --git a/embassy-executor/src/arch/std.rs b/embassy-executor/src/arch/std.rs index 2731e275e..ceaa5c7ab 100644 --- a/embassy-executor/src/arch/std.rs +++ b/embassy-executor/src/arch/std.rs | |||
| @@ -1,9 +1,6 @@ | |||
| 1 | #[cfg(feature = "executor-interrupt")] | 1 | #[cfg(feature = "executor-interrupt")] |
| 2 | compile_error!("`executor-interrupt` is not supported with `arch-std`."); | 2 | compile_error!("`executor-interrupt` is not supported with `arch-std`."); |
| 3 | 3 | ||
| 4 | #[cfg(not(feature = "thread-context"))] | ||
| 5 | compile_error!("`arch-std` requires `thread-context`."); | ||
| 6 | |||
| 7 | #[cfg(feature = "executor-thread")] | 4 | #[cfg(feature = "executor-thread")] |
| 8 | pub use thread::*; | 5 | pub use thread::*; |
| 9 | #[cfg(feature = "executor-thread")] | 6 | #[cfg(feature = "executor-thread")] |
diff --git a/embassy-executor/src/arch/wasm.rs b/embassy-executor/src/arch/wasm.rs index e244c0b3f..c393722b2 100644 --- a/embassy-executor/src/arch/wasm.rs +++ b/embassy-executor/src/arch/wasm.rs | |||
| @@ -1,9 +1,6 @@ | |||
| 1 | #[cfg(feature = "executor-interrupt")] | 1 | #[cfg(feature = "executor-interrupt")] |
| 2 | compile_error!("`executor-interrupt` is not supported with `arch-wasm`."); | 2 | compile_error!("`executor-interrupt` is not supported with `arch-wasm`."); |
| 3 | 3 | ||
| 4 | #[cfg(not(feature = "thread-context"))] | ||
| 5 | compile_error!("`arch-wasm` requires `thread-context`."); | ||
| 6 | |||
| 7 | #[cfg(feature = "executor-thread")] | 4 | #[cfg(feature = "executor-thread")] |
| 8 | pub use thread::*; | 5 | pub use thread::*; |
| 9 | #[cfg(feature = "executor-thread")] | 6 | #[cfg(feature = "executor-thread")] |
diff --git a/embassy-executor/src/arch/xtensa.rs b/embassy-executor/src/arch/xtensa.rs index 54c842025..28abf352c 100644 --- a/embassy-executor/src/arch/xtensa.rs +++ b/embassy-executor/src/arch/xtensa.rs | |||
| @@ -25,9 +25,7 @@ mod thread { | |||
| 25 | pub struct Context; | 25 | pub struct Context; |
| 26 | 26 | ||
| 27 | impl ThreadContext for Context { | 27 | impl ThreadContext for Context { |
| 28 | #[cfg(feature = "thread-context")] | ||
| 29 | fn context(&self) -> OpaqueThreadContext { | 28 | fn context(&self) -> OpaqueThreadContext { |
| 30 | // Enabling thread-context is not incorrect, just wasteful. | ||
| 31 | OpaqueThreadContext(0) | 29 | OpaqueThreadContext(0) |
| 32 | } | 30 | } |
| 33 | 31 | ||
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 7fd29db40..7795f1e4a 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -292,13 +292,6 @@ impl<F: Future + 'static, const N: usize> TaskPool<F, N> { | |||
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | /// Context given to the thread-mode executor's pender. | 294 | /// Context given to the thread-mode executor's pender. |
| 295 | #[cfg(all(feature = "executor-thread", not(feature = "thread-context")))] | ||
| 296 | #[derive(Clone, Copy)] | ||
| 297 | #[repr(transparent)] | ||
| 298 | pub struct OpaqueThreadContext(pub(crate) ()); | ||
| 299 | |||
| 300 | /// Context given to the thread-mode executor's pender. | ||
| 301 | #[cfg(all(feature = "executor-thread", feature = "thread-context"))] | ||
| 302 | #[repr(transparent)] | 295 | #[repr(transparent)] |
| 303 | #[derive(Clone, Copy)] | 296 | #[derive(Clone, Copy)] |
| 304 | pub struct OpaqueThreadContext(pub(crate) usize); | 297 | pub struct OpaqueThreadContext(pub(crate) usize); |
diff --git a/embassy-executor/src/thread.rs b/embassy-executor/src/thread.rs index f977d41e7..ef703003d 100644 --- a/embassy-executor/src/thread.rs +++ b/embassy-executor/src/thread.rs | |||
| @@ -13,7 +13,6 @@ pub trait ThreadContext: Sized { | |||
| 13 | /// | 13 | /// |
| 14 | /// For example, on multi-core systems, this can be used to store the ID of the core that | 14 | /// For example, on multi-core systems, this can be used to store the ID of the core that |
| 15 | /// should be woken up. | 15 | /// should be woken up. |
| 16 | #[cfg(feature = "thread-context")] | ||
| 17 | fn context(&self) -> OpaqueThreadContext; | 16 | fn context(&self) -> OpaqueThreadContext; |
| 18 | 17 | ||
| 19 | /// Waits for the executor to be waken. | 18 | /// Waits for the executor to be waken. |
| @@ -49,16 +48,10 @@ impl<C: ThreadContext> ThreadModeExecutor<C> { | |||
| 49 | } | 48 | } |
| 50 | 49 | ||
| 51 | /// Create a new Executor using the given thread context. | 50 | /// Create a new Executor using the given thread context. |
| 52 | pub fn with_context(thread_context: C) -> Self { | 51 | pub fn with_context(context: C) -> Self { |
| 53 | #[cfg(not(feature = "thread-context"))] | ||
| 54 | let context = OpaqueThreadContext(()); | ||
| 55 | |||
| 56 | #[cfg(feature = "thread-context")] | ||
| 57 | let context = thread_context.context(); | ||
| 58 | |||
| 59 | Self { | 52 | Self { |
| 60 | inner: raw::Executor::new(Pender::Thread(context)), | 53 | inner: raw::Executor::new(Pender::Thread(context.context())), |
| 61 | context: thread_context, | 54 | context, |
| 62 | not_send: PhantomData, | 55 | not_send: PhantomData, |
| 63 | } | 56 | } |
| 64 | } | 57 | } |
