diff options
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index 8cdce92ec..6783c4853 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -15,10 +15,10 @@ mod waker; | |||
| 15 | 15 | ||
| 16 | use core::cell::Cell; | 16 | use core::cell::Cell; |
| 17 | use core::future::Future; | 17 | use core::future::Future; |
| 18 | use core::mem; | ||
| 18 | use core::pin::Pin; | 19 | use core::pin::Pin; |
| 19 | use core::ptr::NonNull; | 20 | use core::ptr::NonNull; |
| 20 | use core::task::{Context, Poll}; | 21 | use core::task::{Context, Poll}; |
| 21 | use core::{mem, ptr}; | ||
| 22 | 22 | ||
| 23 | use atomic_polyfill::{AtomicU32, Ordering}; | 23 | use atomic_polyfill::{AtomicU32, Ordering}; |
| 24 | use critical_section::CriticalSection; | 24 | use critical_section::CriticalSection; |
| @@ -46,7 +46,7 @@ pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2; | |||
| 46 | pub(crate) struct TaskHeader { | 46 | pub(crate) struct TaskHeader { |
| 47 | pub(crate) state: AtomicU32, | 47 | pub(crate) state: AtomicU32, |
| 48 | pub(crate) run_queue_item: RunQueueItem, | 48 | pub(crate) run_queue_item: RunQueueItem, |
| 49 | pub(crate) executor: Cell<*const Executor>, // Valid if state != 0 | 49 | pub(crate) executor: Cell<Option<&'static Executor>>, |
| 50 | poll_fn: unsafe fn(TaskRef), | 50 | poll_fn: unsafe fn(TaskRef), |
| 51 | 51 | ||
| 52 | #[cfg(feature = "integrated-timers")] | 52 | #[cfg(feature = "integrated-timers")] |
| @@ -115,7 +115,7 @@ impl<F: Future + 'static> TaskStorage<F> { | |||
| 115 | raw: TaskHeader { | 115 | raw: TaskHeader { |
| 116 | state: AtomicU32::new(0), | 116 | state: AtomicU32::new(0), |
| 117 | run_queue_item: RunQueueItem::new(), | 117 | run_queue_item: RunQueueItem::new(), |
| 118 | executor: Cell::new(ptr::null()), | 118 | executor: Cell::new(None), |
| 119 | poll_fn: Self::poll, | 119 | poll_fn: Self::poll, |
| 120 | 120 | ||
| 121 | #[cfg(feature = "integrated-timers")] | 121 | #[cfg(feature = "integrated-timers")] |
| @@ -346,7 +346,7 @@ impl Executor { | |||
| 346 | /// In this case, the task's Future must be Send. This is because this is effectively | 346 | /// In this case, the task's Future must be Send. This is because this is effectively |
| 347 | /// sending the task to the executor thread. | 347 | /// sending the task to the executor thread. |
| 348 | pub(super) unsafe fn spawn(&'static self, task: TaskRef) { | 348 | pub(super) unsafe fn spawn(&'static self, task: TaskRef) { |
| 349 | task.header().executor.set(self); | 349 | task.header().executor.set(Some(self)); |
| 350 | 350 | ||
| 351 | #[cfg(feature = "rtos-trace")] | 351 | #[cfg(feature = "rtos-trace")] |
| 352 | trace::task_new(task.as_ptr() as u32); | 352 | trace::task_new(task.as_ptr() as u32); |
| @@ -455,7 +455,7 @@ pub fn wake_task(task: TaskRef) { | |||
| 455 | 455 | ||
| 456 | // We have just marked the task as scheduled, so enqueue it. | 456 | // We have just marked the task as scheduled, so enqueue it. |
| 457 | unsafe { | 457 | unsafe { |
| 458 | let executor = &*header.executor.get(); | 458 | let executor = header.executor.get().unwrap_unchecked(); |
| 459 | executor.enqueue(cs, task); | 459 | executor.enqueue(cs, task); |
| 460 | } | 460 | } |
| 461 | }) | 461 | }) |
