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
impl Lock
sourcepub async fn take_named(name: String) -> Lock
pub async fn take_named(name: String) -> Lock
Take a lock with a given name
sourcepub async fn take_addressed(address: usize) -> Lock
pub async fn take_addressed(address: usize) -> Lock
Take a lock at a given address
sourcepub async fn take_atomic(l: Vec<LockInfo>) -> Lock
pub async fn take_atomic(l: Vec<LockInfo>) -> Lock
Take multiple locks, atomically
If you try to take multiple reord::Lock
s 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.