Lines Matching full:once
12 /// value to be stored by the [`Once`] (`std::sync::Once` can be trivially emulated with
13 /// `Once`).
15 /// Because [`Once::new`] is `const`, this primitive may be used to safely initialize statics.
22 /// static START: spin::Once = spin::Once::new();
28 pub struct Once<T = (), R = Spin> { struct
34 impl<T, R> Default for Once<T, R> { argument
40 impl<T: fmt::Debug, R> fmt::Debug for Once<T, R> { implementation
43 Some(s) => write!(f, "Once {{ data: ") in fmt()
46 None => write!(f, "Once {{ <uninitialized> }}"), in fmt()
53 unsafe impl<T: Send + Sync, R> Sync for Once<T, R> {} implementation
54 unsafe impl<T: Send, R> Send for Once<T, R> {} implementation
65 // Four states that a Once can be in, encoded into the lower bits of `status` in
66 // the Once structure.
133 impl<T, R: RelaxStrategy> Once<T, R> { implementation
134 /// Performs an initialization routine once and only once. The given closure
148 /// This function will panic if the [`Once`] previously panicked while attempting
157 /// static INIT: spin::Once<usize> = spin::Once::new();
176 /// fail, and lets the `Once` in a uninitialized state if it does.
188 /// This function will panic if the [`Once`] previously panicked while attempting
197 /// static INIT: spin::Once<usize> = spin::Once::new();
230 Err(Status::Panicked) => panic!("Once panicked"), in try_call_once_slow()
273 // The destructor for Finish will run, and poison the Once to ensure that other in try_call_once_slow()
297 /// Spins until the [`Once`] contains a value.
299 /// Note that in releases prior to `0.7`, this function had the behaviour of [`Once::poll`].
303 /// This function will panic if the [`Once`] previously panicked while attempting
315 /// Like [`Once::get`], but will spin if the [`Once`] is in the process of being
322 /// This function will panic if the [`Once`] previously panicked while attempting
334 Status::Panicked => panic!("Once previously poisoned by a panicked"), in poll()
340 impl<T, R> Once<T, R> { implementation
341 /// Initialization constant of [`Once`].
349 /// Creates a new [`Once`].
354 /// Creates a new initialized [`Once`].
365 /// While this method itself is safe, accessing the pointer before the [`Once`] has been
374 /// Get a reference to the initialized instance. Must only be called once COMPLETE.
382 /// Get a reference to the initialized instance. Must only be called once COMPLETE.
390 /// Get a reference to the initialized instance. Must only be called once COMPLETE.
398 /// Returns a reference to the inner value if the [`Once`] has been initialized.
401 // nonatomic stores done when initializing, once we have loaded and checked the status. in get()
408 …/// Returns a reference to the inner value on the unchecked assumption that the [`Once`] has been…
412 …/// This is *extremely* unsafe if the `Once` has not already been initialized because a reference …
414 …/// However, this can be useful in some instances for exposing the `Once` to FFI or when the overh…
415 /// checking initialization is unacceptable and the `Once` has already been initialized.
420 …"Attempted to access an uninitialized Once. If this was run without debug checks, this would be un… in get_unchecked()
425 /// Returns a mutable reference to the inner value if the [`Once`] has been initialized.
427 /// Because this method requires a mutable reference to the [`Once`], no synchronization
440 …/// This is *extremely* unsafe if the `Once` has not already been initialized because a reference …
442 …/// However, this can be useful in some instances for exposing the `Once` to FFI or when the overh…
443 /// checking initialization is unacceptable and the `Once` has already been initialized.
448 …"Attempted to access an unintialized Once. If this was to run without debug checks, this would be… in get_mut_unchecked()
453 /// Returns a the inner value if the [`Once`] has been initialized.
455 /// Because this method requires ownership of the [`Once`], no synchronization overhead
464 /// Returns a the inner value if the [`Once`] has been initialized.
467 …/// This is *extremely* unsafe if the `Once` has not already been initialized because a reference …
469 /// This can be useful, if `Once` has already been initialized, and you want to bypass an
475 …"Attempted to access an unintialized Once. If this was to run without debug checks, this would be… in into_inner_unchecked()
491 impl<T, R> From<T> for Once<T, R> { implementation
497 impl<T, R> Drop for Once<T, R> { implementation
502 //TODO: Use MaybeUninit::assume_init_drop once stabilised in drop()
538 static O: Once = Once::new(); in smoke_once()
548 static O: Once<usize> = Once::new(); in smoke_once_value()
557 static O: Once = Once::new(); in stampede_once()
598 static INIT: Once<usize> = Once::new(); in get()
607 static INIT: Once<usize> = Once::new(); in get_no_wait()
623 static INIT: Once<usize> = Once::new(); in poll()
632 static INIT: Once<usize> = Once::new(); in wait()
654 static INIT: Once = Once::new(); in panic()
656 // poison the once in panic()
671 static O: Once = Once::INIT; in init_constant()
693 let once = Once::<_, Spin>::new(); in try_call_once_err() localVariable
694 let shared = Arc::new((once, AtomicU32::new(0))); in try_call_once_err()
701 let (once, called) = &*shared; in try_call_once_err()
703 once.try_call_once(|| { in try_call_once_err()
717 let (once, called) = &*shared; in try_call_once_err()
724 once.call_once(|| { in try_call_once_err()
746 let once = Once::<_>::new(); in drop_occurs_and_skip_uninit_drop() localVariable
747 once.call_once(|| DropTest {}); in drop_occurs_and_skip_uninit_drop()
756 let once = Once::<DropTest>::new(); in drop_occurs_and_skip_uninit_drop() localVariable
757 drop(once); in drop_occurs_and_skip_uninit_drop()
769 let once = Arc::new(Once::<_, Spin>::new()); in call_once_test() localVariable
774 let once = once.clone(); in call_once_test() localVariable
777 once.call_once(|| { in call_once_test()