Skip to content

Commit

Permalink
pub this_task_id
Browse files Browse the repository at this point in the history
  • Loading branch information
ybbh committed Oct 25, 2024
1 parent ebb2c2c commit 5da1c11
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,18 @@ macro_rules! task_backtrace {
};
}

#[macro_export]
macro_rules! this_task_id {
() => {
{
crate::task::this_task_id()
}
};
}
/// The task must create by `task::spawn_local_task`, or `task::spawn_task` to set `TASK_ID` value.
/// if not, the `LocalKey::get` would raise such panic,
/// "cannot access a task-local storage value without setting it first"
fn this_task_id() -> TaskID {
pub fn this_task_id() -> TaskID {
TASK_ID.get()
}

Expand Down

0 comments on commit 5da1c11

Please sign in to comment.