diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index 182dd693..ce5e2741 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 # Architecture _arch = [] # some arch was picked -arch-std = ["_arch", "critical-section/std", "thread-context"] +arch-std = ["_arch", "critical-section/std"] arch-cortex-m = ["_arch", "dep:cortex-m"] arch-xtensa = ["_arch"] arch-riscv32 = ["_arch"] -arch-wasm = ["_arch", "dep:wasm-bindgen", "dep:js-sys", "thread-context"] +arch-wasm = ["_arch", "dep:wasm-bindgen", "dep:js-sys"] # Enable creating a `Pender` from an arbitrary function pointer callback. pender-callback = [] @@ -45,9 +45,6 @@ executor-thread = [] # Enable the interrupt-mode executor (available in Cortex-M only) executor-interrupt = [] -# Pass a context to the thread-mode executor. -thread-context = [] - # Enable nightly-only features nightly = [] diff --git a/embassy-executor/src/arch/cortex_m.rs b/embassy-executor/src/arch/cortex_m.rs index 6c1300ae..a29e5b23 100644 --- a/embassy-executor/src/arch/cortex_m.rs +++ b/embassy-executor/src/arch/cortex_m.rs @@ -21,9 +21,7 @@ mod thread { pub struct Context; impl ThreadContext for Context { - #[cfg(feature = "thread-context")] fn context(&self) -> OpaqueThreadContext { - // Enabling thread-context is not incorrect, just wasteful. OpaqueThreadContext(0) } diff --git a/embassy-executor/src/arch/riscv32.rs b/embassy-executor/src/arch/riscv32.rs index 08720400..976e7bcb 100644 --- a/embassy-executor/src/arch/riscv32.rs +++ b/embassy-executor/src/arch/riscv32.rs @@ -27,9 +27,7 @@ mod thread { pub struct Context; impl ThreadContext for Context { - #[cfg(feature = "thread-context")] fn context(&self) -> OpaqueThreadContext { - // Enabling thread-context is not incorrect, just wasteful. OpaqueThreadContext(0) } diff --git a/embassy-executor/src/arch/std.rs b/embassy-executor/src/arch/std.rs index 2731e275..ceaa5c7a 100644 --- a/embassy-executor/src/arch/std.rs +++ b/embassy-executor/src/arch/std.rs @@ -1,9 +1,6 @@ #[cfg(feature = "executor-interrupt")] compile_error!("`executor-interrupt` is not supported with `arch-std`."); -#[cfg(not(feature = "thread-context"))] -compile_error!("`arch-std` requires `thread-context`."); - #[cfg(feature = "executor-thread")] pub use thread::*; #[cfg(feature = "executor-thread")] diff --git a/embassy-executor/src/arch/wasm.rs b/embassy-executor/src/arch/wasm.rs index e244c0b3..c393722b 100644 --- a/embassy-executor/src/arch/wasm.rs +++ b/embassy-executor/src/arch/wasm.rs @@ -1,9 +1,6 @@ #[cfg(feature = "executor-interrupt")] compile_error!("`executor-interrupt` is not supported with `arch-wasm`."); -#[cfg(not(feature = "thread-context"))] -compile_error!("`arch-wasm` requires `thread-context`."); - #[cfg(feature = "executor-thread")] pub use thread::*; #[cfg(feature = "executor-thread")] diff --git a/embassy-executor/src/arch/xtensa.rs b/embassy-executor/src/arch/xtensa.rs index 54c84202..28abf352 100644 --- a/embassy-executor/src/arch/xtensa.rs +++ b/embassy-executor/src/arch/xtensa.rs @@ -25,9 +25,7 @@ mod thread { pub struct Context; impl ThreadContext for Context { - #[cfg(feature = "thread-context")] fn context(&self) -> OpaqueThreadContext { - // Enabling thread-context is not incorrect, just wasteful. OpaqueThreadContext(0) } diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 7fd29db4..7795f1e4 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs @@ -292,13 +292,6 @@ impl TaskPool { } /// Context given to the thread-mode executor's pender. -#[cfg(all(feature = "executor-thread", not(feature = "thread-context")))] -#[derive(Clone, Copy)] -#[repr(transparent)] -pub struct OpaqueThreadContext(pub(crate) ()); - -/// Context given to the thread-mode executor's pender. -#[cfg(all(feature = "executor-thread", feature = "thread-context"))] #[repr(transparent)] #[derive(Clone, Copy)] pub struct OpaqueThreadContext(pub(crate) usize); diff --git a/embassy-executor/src/thread.rs b/embassy-executor/src/thread.rs index f977d41e..ef703003 100644 --- a/embassy-executor/src/thread.rs +++ b/embassy-executor/src/thread.rs @@ -13,7 +13,6 @@ pub trait ThreadContext: Sized { /// /// For example, on multi-core systems, this can be used to store the ID of the core that /// should be woken up. - #[cfg(feature = "thread-context")] fn context(&self) -> OpaqueThreadContext; /// Waits for the executor to be waken. @@ -49,16 +48,10 @@ impl ThreadModeExecutor { } /// Create a new Executor using the given thread context. - pub fn with_context(thread_context: C) -> Self { - #[cfg(not(feature = "thread-context"))] - let context = OpaqueThreadContext(()); - - #[cfg(feature = "thread-context")] - let context = thread_context.context(); - + pub fn with_context(context: C) -> Self { Self { - inner: raw::Executor::new(Pender::Thread(context)), - context: thread_context, + inner: raw::Executor::new(Pender::Thread(context.context())), + context, not_send: PhantomData, } }