aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw/mod.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-07-08 23:36:51 +0200
committerdiondokter <[email protected]>2025-08-29 13:22:01 +0200
commit2ba34ce2178d576f339f0b0dac70ac125f81cc5b (patch)
tree604ab957e698b371d45c29df7e8099569c1a3df8 /embassy-executor/src/raw/mod.rs
parent658a52fb99e47d3d2f08ebf66335774930ad35ac (diff)
executor: allow trace and rtos-trace to coexist additively.
Before, enabling `trace` would enable embassy-native tracing, and enabling *both* would *disable* embassy-native tracing.
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
-rw-r--r--embassy-executor/src/raw/mod.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs
index bcd4ee432..87328df5a 100644
--- a/embassy-executor/src/raw/mod.rs
+++ b/embassy-executor/src/raw/mod.rs
@@ -16,7 +16,7 @@ mod run_queue;
16#[cfg_attr(not(target_has_atomic = "8"), path = "state_critical_section.rs")] 16#[cfg_attr(not(target_has_atomic = "8"), path = "state_critical_section.rs")]
17mod state; 17mod state;
18 18
19#[cfg(feature = "trace")] 19#[cfg(feature = "_any_trace")]
20pub mod trace; 20pub mod trace;
21pub(crate) mod util; 21pub(crate) mod util;
22#[cfg_attr(feature = "turbowakers", path = "waker_turbo.rs")] 22#[cfg_attr(feature = "turbowakers", path = "waker_turbo.rs")]
@@ -94,9 +94,9 @@ pub(crate) struct TaskHeader {
94 94
95 /// Integrated timer queue storage. This field should not be accessed outside of the timer queue. 95 /// Integrated timer queue storage. This field should not be accessed outside of the timer queue.
96 pub(crate) timer_queue_item: TimerQueueItem, 96 pub(crate) timer_queue_item: TimerQueueItem,
97 #[cfg(feature = "trace")] 97 #[cfg(feature = "_any_trace")]
98 pub(crate) name: Option<&'static str>, 98 pub(crate) name: Option<&'static str>,
99 #[cfg(feature = "trace")] 99 #[cfg(feature = "rtos-trace")]
100 all_tasks_next: AtomicPtr<TaskHeader>, 100 all_tasks_next: AtomicPtr<TaskHeader>,
101} 101}
102 102
@@ -193,9 +193,9 @@ impl<F: Future + 'static> TaskStorage<F> {
193 poll_fn: SyncUnsafeCell::new(None), 193 poll_fn: SyncUnsafeCell::new(None),
194 194
195 timer_queue_item: TimerQueueItem::new(), 195 timer_queue_item: TimerQueueItem::new(),
196 #[cfg(feature = "trace")] 196 #[cfg(feature = "_any_trace")]
197 name: None, 197 name: None,
198 #[cfg(feature = "trace")] 198 #[cfg(feature = "rtos-trace")]
199 all_tasks_next: AtomicPtr::new(core::ptr::null_mut()), 199 all_tasks_next: AtomicPtr::new(core::ptr::null_mut()),
200 }, 200 },
201 future: UninitCell::uninit(), 201 future: UninitCell::uninit(),
@@ -231,7 +231,7 @@ impl<F: Future + 'static> TaskStorage<F> {
231 let mut cx = Context::from_waker(&waker); 231 let mut cx = Context::from_waker(&waker);
232 match future.poll(&mut cx) { 232 match future.poll(&mut cx) {
233 Poll::Ready(_) => { 233 Poll::Ready(_) => {
234 #[cfg(feature = "trace")] 234 #[cfg(feature = "_any_trace")]
235 let exec_ptr: *const SyncExecutor = this.raw.executor.load(Ordering::Relaxed); 235 let exec_ptr: *const SyncExecutor = this.raw.executor.load(Ordering::Relaxed);
236 236
237 // As the future has finished and this function will not be called 237 // As the future has finished and this function will not be called
@@ -246,7 +246,7 @@ impl<F: Future + 'static> TaskStorage<F> {
246 // after we're done with it. 246 // after we're done with it.
247 this.raw.state.despawn(); 247 this.raw.state.despawn();
248 248
249 #[cfg(feature = "trace")] 249 #[cfg(feature = "_any_trace")]
250 trace::task_end(exec_ptr, &p); 250 trace::task_end(exec_ptr, &p);
251 } 251 }
252 Poll::Pending => {} 252 Poll::Pending => {}
@@ -419,7 +419,7 @@ impl SyncExecutor {
419 /// - `task` must NOT be already enqueued (in this executor or another one). 419 /// - `task` must NOT be already enqueued (in this executor or another one).
420 #[inline(always)] 420 #[inline(always)]
421 unsafe fn enqueue(&self, task: TaskRef, l: state::Token) { 421 unsafe fn enqueue(&self, task: TaskRef, l: state::Token) {
422 #[cfg(feature = "trace")] 422 #[cfg(feature = "_any_trace")]
423 trace::task_ready_begin(self, &task); 423 trace::task_ready_begin(self, &task);
424 424
425 if self.run_queue.enqueue(task, l) { 425 if self.run_queue.enqueue(task, l) {
@@ -432,7 +432,7 @@ impl SyncExecutor {
432 .executor 432 .executor
433 .store((self as *const Self).cast_mut(), Ordering::Relaxed); 433 .store((self as *const Self).cast_mut(), Ordering::Relaxed);
434 434
435 #[cfg(feature = "trace")] 435 #[cfg(feature = "_any_trace")]
436 trace::task_new(self, &task); 436 trace::task_new(self, &task);
437 437
438 state::locked(|l| { 438 state::locked(|l| {
@@ -444,23 +444,23 @@ impl SyncExecutor {
444 /// 444 ///
445 /// Same as [`Executor::poll`], plus you must only call this on the thread this executor was created. 445 /// Same as [`Executor::poll`], plus you must only call this on the thread this executor was created.
446 pub(crate) unsafe fn poll(&'static self) { 446 pub(crate) unsafe fn poll(&'static self) {
447 #[cfg(feature = "trace")] 447 #[cfg(feature = "_any_trace")]
448 trace::poll_start(self); 448 trace::poll_start(self);
449 449
450 self.run_queue.dequeue_all(|p| { 450 self.run_queue.dequeue_all(|p| {
451 let task = p.header(); 451 let task = p.header();
452 452
453 #[cfg(feature = "trace")] 453 #[cfg(feature = "_any_trace")]
454 trace::task_exec_begin(self, &p); 454 trace::task_exec_begin(self, &p);
455 455
456 // Run the task 456 // Run the task
457 task.poll_fn.get().unwrap_unchecked()(p); 457 task.poll_fn.get().unwrap_unchecked()(p);
458 458
459 #[cfg(feature = "trace")] 459 #[cfg(feature = "_any_trace")]
460 trace::task_exec_end(self, &p); 460 trace::task_exec_end(self, &p);
461 }); 461 });
462 462
463 #[cfg(feature = "trace")] 463 #[cfg(feature = "_any_trace")]
464 trace::executor_idle(self) 464 trace::executor_idle(self)
465 } 465 }
466} 466}