aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/thread.rs
diff options
context:
space:
mode:
authorDániel Buga <[email protected]>2023-08-12 22:42:50 +0200
committerDániel Buga <[email protected]>2023-08-12 22:42:50 +0200
commit6ab0d71d9246cdc65f392212d03d639a51d21098 (patch)
tree8fbb717373b07d916c2e28d81f37ef9f556d6b13 /embassy-executor/src/thread.rs
parentd5e66f6f87222de65ac575c4b923b2fee5487388 (diff)
Tweak identifiers and comments
Diffstat (limited to 'embassy-executor/src/thread.rs')
-rw-r--r--embassy-executor/src/thread.rs30
1 files changed, 22 insertions, 8 deletions
diff --git a/embassy-executor/src/thread.rs b/embassy-executor/src/thread.rs
index 2d2c6daa5..f977d41e7 100644
--- a/embassy-executor/src/thread.rs
+++ b/embassy-executor/src/thread.rs
@@ -5,13 +5,21 @@ use core::marker::PhantomData;
5use crate::raw::{OpaqueThreadContext, Pender}; 5use crate::raw::{OpaqueThreadContext, Pender};
6use crate::{raw, Spawner}; 6use crate::{raw, Spawner};
7 7
8/// TODO 8/// Architecture-specific interface for a thread-mode executor. This trait describes what the
9// Name pending 9/// executor should do when idle, and what data should be passed to its pender.
10// TODO: Name pending
10pub trait ThreadContext: Sized { 11pub trait ThreadContext: Sized {
11 /// TODO 12 /// A pointer-sized piece of data that is passed to the pender function.
13 ///
14 /// For example, on multi-core systems, this can be used to store the ID of the core that
15 /// should be woken up.
16 #[cfg(feature = "thread-context")]
12 fn context(&self) -> OpaqueThreadContext; 17 fn context(&self) -> OpaqueThreadContext;
13 18
14 /// TODO 19 /// Waits for the executor to be waken.
20 ///
21 /// While it is valid for this function can be empty, it is recommended to use a WFE instruction
22 /// or equivalent to let the CPU sleep.
15 fn wait(&mut self); 23 fn wait(&mut self);
16} 24}
17 25
@@ -40,11 +48,17 @@ impl<C: ThreadContext> ThreadModeExecutor<C> {
40 Self::with_context(C::default()) 48 Self::with_context(C::default())
41 } 49 }
42 50
43 /// Create a new Executor. 51 /// Create a new Executor using the given thread context.
44 pub fn with_context(context: C) -> Self { 52 pub fn with_context(thread_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
45 Self { 59 Self {
46 inner: raw::Executor::new(Pender::Thread(context.context())), 60 inner: raw::Executor::new(Pender::Thread(context)),
47 context, 61 context: thread_context,
48 not_send: PhantomData, 62 not_send: PhantomData,
49 } 63 }
50 } 64 }