use std::sync::Arc;
pub struct MkTaskLocal {
inner: Arc<TaskLocalInner>,
}
struct TaskLocalInner {
parent: Option<Arc<TaskLocalInner>>,
}
impl MkTaskLocal {
pub fn new() -> Self {
Self {
inner: Arc::new(TaskLocalInner { parent: None }),
}
}
pub fn child(&self) -> Self {
Self {
inner: Arc::new(TaskLocalInner {
parent: Some(Arc::clone(&self.inner)),
}),
}
}
pub fn has_parent(&self) -> bool {
self.inner.parent.is_some()
}
}
impl Default for MkTaskLocal {
fn default() -> Self {
Self::new()
}
}
impl Clone for MkTaskLocal {
fn clone(&self) -> Self {
Self {
inner: Arc::clone(&self.inner),
}
}
}