Std.Sync.withLock
1 declaration
fn
withLock: &Std.Sync.Mutex -> fn() -> T -> Result[T, Std.Sync.SyncError]This is a callable function.
What it does
Run an action with a lock held, and release it after the action returns.
There is no unlock a caller can forget, because there is no unlock. A lock
released only on the normal return path would usually be unsafe. Pudu does
not recover from a runtime abort inside the action; program teardown owns
that path and discards all runtime synchronization resources.
Read the signature
- The text after the name is the type checked by Pudu.
- Read arrows from left to right: inputs come first, and the final type is returned.
- & borrows a value for this call instead of moving or copying it.
- Names inside [ ] are type arguments, such as the item type held by a collection.
- Result makes success and recoverable failure part of the function's type.
