add ID field to TaskHeader
This commit is contained in:
parent
54b3fb6e7a
commit
f4e0cbb7cc
@ -91,6 +91,8 @@ pub(crate) struct TaskHeader {
|
|||||||
pub(crate) timer_queue_item: timer_queue::TimerQueueItem,
|
pub(crate) timer_queue_item: timer_queue::TimerQueueItem,
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
pub(crate) name: Option<&'static str>,
|
pub(crate) name: Option<&'static str>,
|
||||||
|
#[cfg(feature = "trace")]
|
||||||
|
pub(crate) id: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is essentially a `&'static TaskStorage<F>` where the type of the future has been erased.
|
/// This is essentially a `&'static TaskStorage<F>` where the type of the future has been erased.
|
||||||
@ -166,6 +168,21 @@ impl TaskRef {
|
|||||||
(*header_ptr).name = name;
|
(*header_ptr).name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the ID for a task
|
||||||
|
#[cfg(feature = "trace")]
|
||||||
|
pub fn id(&self) -> u32 {
|
||||||
|
self.header().id
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set the ID for a task
|
||||||
|
#[cfg(feature = "trace")]
|
||||||
|
pub fn set_id(&self, id: u32) {
|
||||||
|
unsafe {
|
||||||
|
let header_ptr = self.ptr.as_ptr() as *mut TaskHeader;
|
||||||
|
(*header_ptr).id = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Raw storage in which a task can be spawned.
|
/// Raw storage in which a task can be spawned.
|
||||||
@ -209,6 +226,8 @@ impl<F: Future + 'static> TaskStorage<F> {
|
|||||||
timer_queue_item: timer_queue::TimerQueueItem::new(),
|
timer_queue_item: timer_queue::TimerQueueItem::new(),
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
name: None,
|
name: None,
|
||||||
|
#[cfg(feature = "trace")]
|
||||||
|
id: 0,
|
||||||
},
|
},
|
||||||
future: UninitCell::uninit(),
|
future: UninitCell::uninit(),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -174,6 +174,7 @@ impl Spawner {
|
|||||||
task.set_name(Some(name));
|
task.set_name(Some(name));
|
||||||
let task_id = task.as_ptr() as u32;
|
let task_id = task.as_ptr() as u32;
|
||||||
TASK_REGISTRY.register(task_id);
|
TASK_REGISTRY.register(task_id);
|
||||||
|
task.set_id(task_id);
|
||||||
|
|
||||||
unsafe { self.executor.spawn(task) };
|
unsafe { self.executor.spawn(task) };
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user