aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-executor')
-rw-r--r--embassy-executor/Cargo.toml7
-rw-r--r--embassy-executor/src/arch/cortex_m.rs2
-rw-r--r--embassy-executor/src/arch/riscv32.rs2
-rw-r--r--embassy-executor/src/arch/std.rs3
-rw-r--r--embassy-executor/src/arch/wasm.rs3
-rw-r--r--embassy-executor/src/arch/xtensa.rs2
-rw-r--r--embassy-executor/src/raw/mod.rs7
-rw-r--r--embassy-executor/src/thread.rs13
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
34arch-std = ["_arch", "critical-section/std", "thread-context"] 34arch-std = ["_arch", "critical-section/std"]
35arch-cortex-m = ["_arch", "dep:cortex-m"] 35arch-cortex-m = ["_arch", "dep:cortex-m"]
36arch-xtensa = ["_arch"] 36arch-xtensa = ["_arch"]
37arch-riscv32 = ["_arch"] 37arch-riscv32 = ["_arch"]
38arch-wasm = ["_arch", "dep:wasm-bindgen", "dep:js-sys", "thread-context"] 38arch-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.
41pender-callback = [] 41pender-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)
46executor-interrupt = [] 46executor-interrupt = []
47 47
48# Pass a context to the thread-mode executor.
49thread-context = []
50
51# Enable nightly-only features 48# Enable nightly-only features
52nightly = [] 49nightly = []
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")]
2compile_error!("`executor-interrupt` is not supported with `arch-std`."); 2compile_error!("`executor-interrupt` is not supported with `arch-std`.");
3 3
4#[cfg(not(feature = "thread-context"))]
5compile_error!("`arch-std` requires `thread-context`.");
6
7#[cfg(feature = "executor-thread")] 4#[cfg(feature = "executor-thread")]
8pub use thread::*; 5pub 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")]
2compile_error!("`executor-interrupt` is not supported with `arch-wasm`."); 2compile_error!("`executor-interrupt` is not supported with `arch-wasm`.");
3 3
4#[cfg(not(feature = "thread-context"))]
5compile_error!("`arch-wasm` requires `thread-context`.");
6
7#[cfg(feature = "executor-thread")] 4#[cfg(feature = "executor-thread")]
8pub use thread::*; 5pub 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)]
298pub 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)]
304pub struct OpaqueThreadContext(pub(crate) usize); 297pub 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 }