diff options
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 87328df5a..a7e65360d 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -41,6 +41,7 @@ use self::state::State; | |||
| 41 | use self::util::{SyncUnsafeCell, UninitCell}; | 41 | use self::util::{SyncUnsafeCell, UninitCell}; |
| 42 | pub use self::waker::task_from_waker; | 42 | pub use self::waker::task_from_waker; |
| 43 | use super::SpawnToken; | 43 | use super::SpawnToken; |
| 44 | use crate::Metadata; | ||
| 44 | 45 | ||
| 45 | #[no_mangle] | 46 | #[no_mangle] |
| 46 | extern "Rust" fn __embassy_time_queue_item_from_waker(waker: &Waker) -> &'static mut TimerQueueItem { | 47 | extern "Rust" fn __embassy_time_queue_item_from_waker(waker: &Waker) -> &'static mut TimerQueueItem { |
| @@ -94,8 +95,9 @@ pub(crate) struct TaskHeader { | |||
| 94 | 95 | ||
| 95 | /// Integrated timer queue storage. This field should not be accessed outside of the timer queue. | 96 | /// Integrated timer queue storage. This field should not be accessed outside of the timer queue. |
| 96 | pub(crate) timer_queue_item: TimerQueueItem, | 97 | pub(crate) timer_queue_item: TimerQueueItem, |
| 97 | #[cfg(feature = "_any_trace")] | 98 | |
| 98 | pub(crate) name: Option<&'static str>, | 99 | pub(crate) metadata: Metadata, |
| 100 | |||
| 99 | #[cfg(feature = "rtos-trace")] | 101 | #[cfg(feature = "rtos-trace")] |
| 100 | all_tasks_next: AtomicPtr<TaskHeader>, | 102 | all_tasks_next: AtomicPtr<TaskHeader>, |
| 101 | } | 103 | } |
| @@ -127,6 +129,10 @@ impl TaskRef { | |||
| 127 | unsafe { self.ptr.as_ref() } | 129 | unsafe { self.ptr.as_ref() } |
| 128 | } | 130 | } |
| 129 | 131 | ||
| 132 | pub(crate) fn metadata(self) -> &'static Metadata { | ||
| 133 | unsafe { &self.ptr.as_ref().metadata } | ||
| 134 | } | ||
| 135 | |||
| 130 | /// Returns a reference to the executor that the task is currently running on. | 136 | /// Returns a reference to the executor that the task is currently running on. |
| 131 | pub unsafe fn executor(self) -> Option<&'static Executor> { | 137 | pub unsafe fn executor(self) -> Option<&'static Executor> { |
| 132 | let executor = self.header().executor.load(Ordering::Relaxed); | 138 | let executor = self.header().executor.load(Ordering::Relaxed); |
| @@ -193,8 +199,7 @@ impl<F: Future + 'static> TaskStorage<F> { | |||
| 193 | poll_fn: SyncUnsafeCell::new(None), | 199 | poll_fn: SyncUnsafeCell::new(None), |
| 194 | 200 | ||
| 195 | timer_queue_item: TimerQueueItem::new(), | 201 | timer_queue_item: TimerQueueItem::new(), |
| 196 | #[cfg(feature = "_any_trace")] | 202 | metadata: Metadata::new(), |
| 197 | name: None, | ||
| 198 | #[cfg(feature = "rtos-trace")] | 203 | #[cfg(feature = "rtos-trace")] |
| 199 | all_tasks_next: AtomicPtr::new(core::ptr::null_mut()), | 204 | all_tasks_next: AtomicPtr::new(core::ptr::null_mut()), |
| 200 | }, | 205 | }, |
| @@ -281,6 +286,7 @@ impl<F: Future + 'static> AvailableTask<F> { | |||
| 281 | 286 | ||
| 282 | fn initialize_impl<S>(self, future: impl FnOnce() -> F) -> SpawnToken<S> { | 287 | fn initialize_impl<S>(self, future: impl FnOnce() -> F) -> SpawnToken<S> { |
| 283 | unsafe { | 288 | unsafe { |
| 289 | self.task.raw.metadata.reset(); | ||
| 284 | self.task.raw.poll_fn.set(Some(TaskStorage::<F>::poll)); | 290 | self.task.raw.poll_fn.set(Some(TaskStorage::<F>::poll)); |
| 285 | self.task.future.write_in_place(future); | 291 | self.task.future.write_in_place(future); |
| 286 | 292 | ||
