Struct reord::Lock

source ·
pub struct Lock { /* private fields */ }
Expand description

Lock handling

This records, for reord, which locks are currently taken by the program. The lock should be acquired as close as possible before the real lock acquiring, and released as soon as possible after the real lock release.

In addition, there should be a reord::point().await just after the real lock managed to be acquired, and one ideally just after the real lock was released, though this may be harder due to early returns and the current absence of async Drop.

If too long passes with reord unaware of the state of your locks, you could end up with non-reproducible behavior, due to two execution threads actually running in parallel on your executor.

Implementations§

source§

impl Lock

source

pub async fn take_named(name: String) -> Lock

Take a lock with a given name

source

pub async fn take_addressed(address: usize) -> Lock

Take a lock at a given address

source

pub async fn take_atomic(l: Vec<LockInfo>) -> Lock

Take multiple locks, atomically

If you try to take multiple reord::Locks one after the other before locking them atomically, then reord will think that your first lock failed to actually lock. In order to avoid this, you should use reord::Lock::take_atomic to take multiple locks.

Trait Implementations§

source§

impl Debug for Lock

source§

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

Formats the value using the given formatter. Read more
source§

impl Drop for Lock

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Lock

§

impl Send for Lock

§

impl Sync for Lock

§

impl Unpin for Lock

§

impl UnwindSafe for Lock

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V