Lines Matching defs:OnceCell
8 pub(crate) struct OnceCell<T> {
10 // Use `unsync::OnceCell` internally since `Mutex` does not provide
12 value: Mutex<unsync::OnceCell<T>>,
16 // Thread A creates a `OnceCell` and shares it with
20 unsafe impl<T: Sync + Send> Sync for OnceCell<T> {}
21 unsafe impl<T: Send> Send for OnceCell<T> {}
23 impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceCell<T> {}
24 impl<T: UnwindSafe> UnwindSafe for OnceCell<T> {}
26 impl<T> OnceCell<T> {
27 pub(crate) const fn new() -> OnceCell<T> {
28 OnceCell { initialized: AtomicBool::new(false), value: Mutex::new(unsync::OnceCell::new()) }
31 pub(crate) const fn with_value(value: T) -> OnceCell<T> {
32 OnceCell {
34 value: Mutex::new(unsync::OnceCell::with_value(value)),