Remove thread-context feature

This commit is contained in:
Dániel Buga 2023-08-14 08:22:22 +02:00
parent 6ab0d71d92
commit ec6bd27df6
8 changed files with 5 additions and 34 deletions

View File

@ -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 = []

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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")]

View File

@ -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")]

View File

@ -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)
}

View File

@ -292,13 +292,6 @@ impl<F: Future + 'static, const N: usize> TaskPool<F, N> {
}
/// 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);

View File

@ -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<C: ThreadContext> ThreadModeExecutor<C> {
}
/// 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,
}
}