Struct static_init::UnSyncLockedLazy
source · [−]pub struct UnSyncLockedLazy<T, G = fn() -> T> { /* private fields */ }
Expand description
A RefCell that initializes its content on the first access
Implementations
sourceimpl<T, G> UnSyncLockedLazy<T, G> where
G: Generator<T>,
impl<T, G> UnSyncLockedLazy<T, G> where
G: Generator<T>,
sourceimpl<T, G> UnSyncLockedLazy<T, G> where
G: Generator<T>,
impl<T, G> UnSyncLockedLazy<T, G> where
G: Generator<T>,
sourcepub fn read(&self) -> ReadGuard<'_, T>
pub fn read(&self) -> ReadGuard<'_, T>
Initialize if necessary and returns a read lock
Panic
Panics if initialization panics or if initialization has panicked in a previous attempt to initialize.
sourcepub fn fast_read(&self) -> Option<ReadGuard<'_, T>>
pub fn fast_read(&self) -> Option<ReadGuard<'_, T>>
Initialize if necessary and returns some read lock if the lazy is not
already write locked. If the lazy is already write locked it returns None
Panic
If locks succeeds, panics if initialization panics or if initialization has panicked in a previous attempt to initialize.
sourcepub fn try_read(&self) -> Result<ReadGuard<'_, T>, AccessError>
pub fn try_read(&self) -> Result<ReadGuard<'_, T>, AccessError>
Get a read lock if the lazy is initialized or an AccessError
sourcepub fn fast_try_read(&self) -> Option<Result<ReadGuard<'_, T>, AccessError>>
pub fn fast_try_read(&self) -> Option<Result<ReadGuard<'_, T>, AccessError>>
if the lazy is not already write locked: get a read lock if the lazy is initialized or an AccessError.
Otherwise returns None
sourcepub fn write(&self) -> WriteGuard<'_, T>
pub fn write(&self) -> WriteGuard<'_, T>
Initialize if necessary and returns a write lock
Panic
Panics if initialization panics or if initialization has panicked in a previous attempt to initialize.
sourcepub fn fast_write(&self) -> Option<WriteGuard<'_, T>>
pub fn fast_write(&self) -> Option<WriteGuard<'_, T>>
Initialize if necessary and returns some write lock if the lazy is not
already write locked. If the lazy is already read or write locked it returns None
Panic
If locks succeeds, panics if initialization panics or if initialization has panicked in a previous attempt to initialize.
sourcepub fn try_write(&self) -> Result<WriteGuard<'_, T>, AccessError>
pub fn try_write(&self) -> Result<WriteGuard<'_, T>, AccessError>
Get a read lock if the lazy is initialized or an AccessError
sourcepub fn fast_try_write(&self) -> Option<Result<WriteGuard<'_, T>, AccessError>>
pub fn fast_try_write(&self) -> Option<Result<WriteGuard<'_, T>, AccessError>>
if the lazy is not already read or write locked: get a write lock if the lazy is initialized or an AccessError . Otherwise returns None
sourceimpl<T, G> UnSyncLockedLazy<T, G>
impl<T, G> UnSyncLockedLazy<T, G>
sourcepub const fn from_generator(f: G) -> Self
pub const fn from_generator(f: G) -> Self
Build a new static object.
Safety
This function may be unsafe if build this object as anything else than a static or a thread local static would be the cause of undefined behavior
sourcepub const fn from_generator_with_info(f: G, info: StaticInfo) -> Self
pub const fn from_generator_with_info(f: G, info: StaticInfo) -> Self
Build a new static object with debug informations.
Safety
This function may be unsafe if build this object as anything else than a static or a thread local static would be the cause of undefined behavior
sourceimpl<T, G> UnSyncLockedLazy<T, Cell<Option<G>>> where
G: FnOnce() -> T,
impl<T, G> UnSyncLockedLazy<T, Cell<Option<G>>> where
G: FnOnce() -> T,
sourceimpl<T, G: Generator<T>> UnSyncLockedLazy<T, G>
impl<T, G: Generator<T>> UnSyncLockedLazy<T, G>
sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Initialize and return a mutable reference to the target
This method is extremly efficient as it does not requires any form of locking when initializing
sourcepub fn try_get_mut(&mut self) -> Result<&mut T, AccessError>
pub fn try_get_mut(&mut self) -> Result<&mut T, AccessError>
Return a mutable reference to the target if initialized otherwise return an error.
This method is extremly efficient as it does not requires any form of locking when initializing
Trait Implementations
sourceimpl<T: Debug, G> Debug for UnSyncLockedLazy<T, G> where
G: Generator<T>,
impl<T: Debug, G> Debug for UnSyncLockedLazy<T, G> where
G: Generator<T>,
sourceimpl<T: Default> Default for UnSyncLockedLazy<T, fn() -> T>
impl<T: Default> Default for UnSyncLockedLazy<T, fn() -> T>
sourceimpl<T, G> Drop for UnSyncLockedLazy<T, G>
impl<T, G> Drop for UnSyncLockedLazy<T, G>
Auto Trait Implementations
impl<T, G> RefUnwindSafe for UnSyncLockedLazy<T, G> where
G: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, G = fn() -> T> !Send for UnSyncLockedLazy<T, G>
impl<T, G = fn() -> T> !Sync for UnSyncLockedLazy<T, G>
impl<T, G> Unpin for UnSyncLockedLazy<T, G> where
G: Unpin,
T: Unpin,
impl<T, G> UnwindSafe for UnSyncLockedLazy<T, G> where
G: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more