1pub(crate) mod futures {
2 pub(crate) use futures::task;
3 pub(crate) use task::AtomicTask;
4}
5
6pub(crate) mod sync {
7 pub(crate) use std::sync::atomic;
8 pub(crate) use std::sync::Arc;
9
10 use std::cell::UnsafeCell;
11
12 pub(crate) struct CausalCell<T>(UnsafeCell<T>);
13
14 impl<T> CausalCell<T> {
15 pub(crate) fn new(data: T) -> CausalCell<T> {
16 CausalCell(UnsafeCell::new(data))
17 }
18
19 pub(crate) fn with<F, R>(&self, f: F) -> R
20 where
21 F: FnOnce(*const T) -> R,
22 {
23 f(self.0.get())
24 }
25
26 pub(crate) fn with_mut<F, R>(&self, f: F) -> R
27 where
28 F: FnOnce(*mut T) -> R,
29 {
30 f(self.0.get())
31 }
32 }
33}
34
35pub(crate) fn yield_now() {
36 ::std::sync::atomic::spin_loop_hint();
37}