pub struct OwnerLock { /* private fields */ }Expand description
What:
A held owner lock.
Releasing it proves the lock still names this holder first.
Dropping an unreleased lock releases it and ignores a failure.
Why:
An early return or an unwinding error must not leave a live-looking lock behind;
an explicit release reports a changed owner.
In TS you’d write (pseudocode):
type OwnerLock = AsyncDisposable & { lockDirectory: string; token: string };Implementations§
Source§impl OwnerLock
Accessors and release of a held lock.
impl OwnerLock
Accessors and release of a held lock.
Sourcepub fn inherited(directory: &Path, token: &str) -> OwnerLock
pub fn inherited(directory: &Path, token: &str) -> OwnerLock
What:
A view of a lock an ancestor process holds, which releases nothing.
Why:
An invocation nested under a landing-lock holder proves it with an inherited lease and proceeds under the
ancestor’s lock instead of waiting for it (inheritedLandingLock in the incumbent).
In TS you’d write (pseudocode):
{ lockDirectory, token: process.env[LANDING_LEASE_ENV], [Symbol.asyncDispose]: async () => {} }Sourcepub fn directory(&self) -> &Path
pub fn directory(&self) -> &Path
What: The published lock directory. Why: Leases and diagnostics name the lock.
In TS you’d write (pseudocode):
lock.lockDirectorySourcepub fn token(&self) -> &str
pub fn token(&self) -> &str
What: The token this holder published. Why: A lease proves which acquisition it belongs to.
In TS you’d write (pseudocode):
lock.tokenSourcepub fn release(self) -> Result<(), OwnerLockError>
pub fn release(self) -> Result<(), OwnerLockError>
What:
Release the lock,
failing when it no longer names this holder.
mut self takes ownership:
a released lock cannot be used again.
Why:
The release is the incumbent’s releaseHeldLock.
In TS you’d write (pseudocode):
await lock[Symbol.asyncDispose]();Trait Implementations§
Source§impl Drop for OwnerLock
Dropping an unreleased lock releases it.
impl Drop for OwnerLock
Dropping an unreleased lock releases it.
Auto Trait Implementations§
impl Freeze for OwnerLock
impl RefUnwindSafe for OwnerLock
impl Send for OwnerLock
impl Sync for OwnerLock
impl Unpin for OwnerLock
impl UnsafeUnpin for OwnerLock
impl UnwindSafe for OwnerLock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more