Skip to main content

pistonite_cu/cli/
thread_name.rs

1use std::cell::RefCell;
2
3thread_local! {
4    pub(crate) static THREAD_NAME: RefCell<Option<String>> = const { RefCell::new(None) };
5}
6
7/// Set the name to show up in messages printed by the current thread
8#[inline(always)]
9pub fn set_thread_name(name: impl Into<String>) {
10    THREAD_NAME.with_borrow_mut(|x| *x = Some(name.into()))
11}
12
13/// Reset the current thread to not show a name
14#[inline(always)]
15pub fn reset_thread_name() {
16    THREAD_NAME.with_borrow_mut(|x| *x = None)
17}