aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw
diff options
context:
space:
mode:
authorKat Perez <[email protected]>2025-05-06 09:59:27 -0400
committerKat Perez <[email protected]>2025-05-06 09:59:27 -0400
commitf4e0cbb7cc476b171acd0b21448e9bbc848a616d (patch)
treec46f373ae9ff017d2a7767e51b769938ec7a09d6 /embassy-executor/src/raw
parent54b3fb6e7a12598e0f6299c18a333060d6a3f9c7 (diff)
add ID field to TaskHeader
Diffstat (limited to 'embassy-executor/src/raw')
-rw-r--r--embassy-executor/src/raw/mod.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs
index 3f4e06350..075d8a254 100644
--- a/embassy-executor/src/raw/mod.rs
+++ b/embassy-executor/src/raw/mod.rs
@@ -91,6 +91,8 @@ pub(crate) struct TaskHeader {
91 pub(crate) timer_queue_item: timer_queue::TimerQueueItem, 91 pub(crate) timer_queue_item: timer_queue::TimerQueueItem,
92 #[cfg(feature = "trace")] 92 #[cfg(feature = "trace")]
93 pub(crate) name: Option<&'static str>, 93 pub(crate) name: Option<&'static str>,
94 #[cfg(feature = "trace")]
95 pub(crate) id: u32,
94} 96}
95 97
96/// This is essentially a `&'static TaskStorage<F>` where the type of the future has been erased. 98/// This is essentially a `&'static TaskStorage<F>` where the type of the future has been erased.
@@ -166,6 +168,21 @@ impl TaskRef {
166 (*header_ptr).name = name; 168 (*header_ptr).name = name;
167 } 169 }
168 } 170 }
171
172 /// Get the ID for a task
173 #[cfg(feature = "trace")]
174 pub fn id(&self) -> u32 {
175 self.header().id
176 }
177
178 /// Set the ID for a task
179 #[cfg(feature = "trace")]
180 pub fn set_id(&self, id: u32) {
181 unsafe {
182 let header_ptr = self.ptr.as_ptr() as *mut TaskHeader;
183 (*header_ptr).id = id;
184 }
185 }
169} 186}
170 187
171/// Raw storage in which a task can be spawned. 188/// Raw storage in which a task can be spawned.
@@ -209,6 +226,8 @@ impl<F: Future + 'static> TaskStorage<F> {
209 timer_queue_item: timer_queue::TimerQueueItem::new(), 226 timer_queue_item: timer_queue::TimerQueueItem::new(),
210 #[cfg(feature = "trace")] 227 #[cfg(feature = "trace")]
211 name: None, 228 name: None,
229 #[cfg(feature = "trace")]
230 id: 0,
212 }, 231 },
213 future: UninitCell::uninit(), 232 future: UninitCell::uninit(),
214 } 233 }