Struct static_init::lazy::PrimedLockedLazy

source ·
pub struct PrimedLockedLazy<T, G = fn() -> T> { /* private fields */ }
Expand description

The actual type of mutable statics attributed with #[dynamic(primed)]

Implementations§

source§

impl<T, G> PrimedLockedLazy<T, G>
where T: 'static, G: 'static + Generator<T>,

source

pub fn phase(&'static self) -> Phase

Returns the current phase and synchronize with the end of the transition to the returned phase.

source§

impl<T, G> PrimedLockedLazy<T, G>
where G: 'static + Generator<T>, T: 'static,

source

pub fn read(&'static 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.

source

pub fn fast_read(&'static 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.

source

pub fn try_read(&'static self) -> Result<ReadGuard<'_, T>, AccessError>

Get a read lock if the lazy is initialized or an AccessError

source

pub fn fast_try_read( &'static 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

source

pub fn write(&'static 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.

source

pub fn fast_write(&'static 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.

source

pub fn try_write(&'static self) -> Result<WriteGuard<'_, T>, AccessError>

Get a read lock if the lazy is initialized or an AccessError

source

pub fn fast_try_write( &'static 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

source

pub fn init(&'static self)

Initialize the lazy if no previous attempt to initialized it where performed

source§

impl<T, G> PrimedLockedLazy<T, G>

source

pub const fn from_generator(v: T, 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

source

pub const fn from_generator_with_info(v: T, 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

source§

impl<T, G> PrimedLockedLazy<T, G>
where G: 'static + Generator<T>, T: 'static,

source

pub fn primed_read_non_initializing( &'static self, ) -> Result<ReadGuard<'_, T>, ReadGuard<'_, T>>

Return a read lock to the initialized value or an error containing a read lock to the primed or post uninited value

source

pub fn primed_read(&'static self) -> Result<ReadGuard<'_, T>, ReadGuard<'_, T>>

Initialize if possible and either return a read lock to the initialized value or an error containing a read lock to the primed or post uninited value

source

pub fn primed_write_non_initializing( &'static self, ) -> Result<WriteGuard<'_, T>, ReadGuard<'_, T>>

Return a write lock that refers to the initialized value or an error containing a read lock that refers to the primed or post uninited value

source

pub fn primed_write( &'static self, ) -> Result<WriteGuard<'_, T>, ReadGuard<'_, T>>

Initialize if possible and either return a write lock that refers to the initialized value or an error containing a read lock that refers to the primed or post uninited value

Trait Implementations§

source§

impl<T, G> Phased for PrimedLockedLazy<T, G>
where T: 'static, G: 'static + Generator<T>,

source§

fn phase(this: &Self) -> Phase

return the current phase

Auto Trait Implementations§

§

impl<T, G = fn() -> T> !Freeze for PrimedLockedLazy<T, G>

§

impl<T, G = fn() -> T> !RefUnwindSafe for PrimedLockedLazy<T, G>

§

impl<T, G> Send for PrimedLockedLazy<T, G>
where G: Send + Sync, T: Send,

§

impl<T, G> Sync for PrimedLockedLazy<T, G>
where G: Sync, T: Send,

§

impl<T, G> Unpin for PrimedLockedLazy<T, G>
where G: Unpin, T: Unpin,

§

impl<T, G> UnwindSafe for PrimedLockedLazy<T, G>
where G: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.