MutexRef
struct MutexRefA non-owning lock/unlock view of an initialised mutex blob.
This is what a worker thread reconstructs from an address it found in its context block. It initialises nothing and frees nothing.
Implements Copyable, ImplicitlyCopyable, Movable
at
def at(address: Int) -> Self View the mutex whose blob starts at address.
- Args
address: FromMutex.address().
address
def address(self) -> Int Return the blob address.
lock
def lock(self) Block until this thread holds the mutex.
unlock
def unlock(self) Release the mutex. Only the holding thread may call this.
try_lock
def try_lock(self) -> Bool Take the mutex if it is free, without blocking.
with_lock
def with_lock[body: def(Pointer[UInt8, MutUntrackedOrigin]) thin -> None](self, ctx: Pointer[UInt8, MutUntrackedOrigin]) Run body(ctx) with the mutex held, then release it.
- Parameters
body: A thin, non-raising function. Non-raising is load-bearing: an escaping exception would skip the unlock.
- Args
ctx: Passed straight through tobody.