memkit_async/
task_local.rs1use std::sync::Arc;
4
5pub struct MkTaskLocal {
10 inner: Arc<TaskLocalInner>,
11}
12
13struct TaskLocalInner {
14 parent: Option<Arc<TaskLocalInner>>,
15 }
17
18impl MkTaskLocal {
19 pub fn new() -> Self {
21 Self {
22 inner: Arc::new(TaskLocalInner { parent: None }),
23 }
24 }
25
26 pub fn child(&self) -> Self {
28 Self {
29 inner: Arc::new(TaskLocalInner {
30 parent: Some(Arc::clone(&self.inner)),
31 }),
32 }
33 }
34
35 pub fn has_parent(&self) -> bool {
37 self.inner.parent.is_some()
38 }
39}
40
41impl Default for MkTaskLocal {
42 fn default() -> Self {
43 Self::new()
44 }
45}
46
47impl Clone for MkTaskLocal {
48 fn clone(&self) -> Self {
49 Self {
50 inner: Arc::clone(&self.inner),
51 }
52 }
53}