Skip to main content

LockToken

Struct LockToken 

Source
pub struct LockToken<T> { /* private fields */ }
Expand description

A token indicating a locked interface.

Implementations§

Source§

impl LockToken<Unlock>

Source

pub unsafe fn relinquish_locking(self) -> LockToken<ForgetUnlock>

Takes ownership of the token and exchanges it with a token which does not unlock the interface.

§Safety

Improper usage can leave the interface in a locked state.

Source§

impl LockToken<ForgetUnlock>

Source

pub unsafe fn take_ownership(self) -> LockToken<Unlock>

Takes ownership of the token and exchanges it with a token which unlocks the interface.

§Safety

Improper usage can unlock the interface multiple times.

Source§

impl<T> LockToken<T>

Source

pub fn lock() -> LockToken<Unlock>

Constructs a new token by locking the interface.

The calling thread is stalled until the lock can be acquired. Only one thread can hold the lock at a time.

§Return

A token.

Source

pub fn try_lock() -> Option<LockToken<Unlock>>

Tries to lock the interface.

The function fails if another thread already holds the lock.

§Return

LockToken on success and None otherwise.

Source

pub unsafe fn assume_locked() -> LockToken<ForgetUnlock>

Constructs a new token without locking.

§Return

A token.

§Safety

Most of the interface assumes that the caller has unique access to the interface. This function can be used to bypass this restriction, if the user can guarantee that no data-races will occur.

Trait Implementations§

Source§

impl<T: Debug> Debug for LockToken<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for LockToken<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for LockToken<T>
where T: RefUnwindSafe,

§

impl<T> Send for LockToken<T>
where T: Send,

§

impl<T> Sync for LockToken<T>
where T: Sync,

§

impl<T> Unpin for LockToken<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for LockToken<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for LockToken<T>
where 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>,

Source§

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>,

Source§

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.