Fix task_end callback

This commit is contained in:
James Munns 2025-04-01 14:23:39 +02:00
parent 8a8e450053
commit c3efb85b85
2 changed files with 7 additions and 3 deletions

View File

@ -219,6 +219,9 @@ impl<F: Future + 'static> TaskStorage<F> {
let mut cx = Context::from_waker(&waker);
match future.poll(&mut cx) {
Poll::Ready(_) => {
#[cfg(feature = "trace")]
let exec_ptr: *const SyncExecutor = this.raw.executor.load(Ordering::Relaxed);
// As the future has finished and this function will not be called
// again, we can safely drop the future here.
this.future.drop_in_place();
@ -232,7 +235,7 @@ impl<F: Future + 'static> TaskStorage<F> {
this.raw.state.despawn();
#[cfg(feature = "trace")]
trace::task_end(self, &task);
trace::task_end(exec_ptr, &p);
}
Poll::Pending => {}
}

View File

@ -84,6 +84,7 @@
//! 5. The executor has finished polling tasks. `_embassy_trace_executor_idle` is called.
#![allow(unused)]
use crate::raw::{SyncExecutor, TaskRef};
#[cfg(not(feature = "rtos-trace"))]
@ -163,10 +164,10 @@ pub(crate) fn task_new(executor: &SyncExecutor, task: &TaskRef) {
}
#[inline]
pub(crate) fn task_end(executor: &SyncExecutor, task: &TaskRef) {
pub(crate) fn task_end(executor: *const SyncExecutor, task: &TaskRef) {
#[cfg(not(feature = "rtos-trace"))]
unsafe {
_embassy_trace_task_end(executor as *const _ as u32, task.as_ptr() as u32)
_embassy_trace_task_end(executor as u32, task.as_ptr() as u32)
}
}