aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/spawner.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-executor/src/spawner.rs')
-rw-r--r--embassy-executor/src/spawner.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/embassy-executor/src/spawner.rs b/embassy-executor/src/spawner.rs
index ff243081c..ea754341b 100644
--- a/embassy-executor/src/spawner.rs
+++ b/embassy-executor/src/spawner.rs
@@ -5,6 +5,8 @@ use core::sync::atomic::Ordering;
5use core::task::Poll; 5use core::task::Poll;
6 6
7use super::raw; 7use super::raw;
8#[cfg(feature = "rtos-trace")]
9use super::raw::trace::TASK_REGISTRY;
8 10
9/// Token to spawn a newly-created task in an executor. 11/// Token to spawn a newly-created task in an executor.
10/// 12///
@@ -154,6 +156,31 @@ impl Spawner {
154 } 156 }
155 } 157 }
156 158
159 /// Spawns a new task with a specified name.
160 ///
161 /// # Arguments
162 /// * `name` - Static string name to associate with the task
163 /// * `token` - Token representing the task to spawn
164 ///
165 /// # Returns
166 /// Result indicating whether the spawn was successful
167 #[cfg(feature = "rtos-trace")]
168 pub fn spawn_named<S>(&self, name: &'static str, token: SpawnToken<S>) -> Result<(), SpawnError> {
169 let task = token.raw_task;
170 mem::forget(token);
171
172 match task {
173 Some(task) => {
174 let task_id = task.as_ptr() as u32;
175 TASK_REGISTRY.register(task_id, Some(name));
176
177 unsafe { self.executor.spawn(task) };
178 Ok(())
179 }
180 None => Err(SpawnError::Busy),
181 }
182 }
183
157 // Used by the `embassy_executor_macros::main!` macro to throw an error when spawn 184 // Used by the `embassy_executor_macros::main!` macro to throw an error when spawn
158 // fails. This is here to allow conditional use of `defmt::unwrap!` 185 // fails. This is here to allow conditional use of `defmt::unwrap!`
159 // without introducing a `defmt` feature in the `embassy_executor_macros` package, 186 // without introducing a `defmt` feature in the `embassy_executor_macros` package,