Picos_std_sync.LockA poisonable mutual exclusion lock.
🏎️ This uses a low overhead, optimistic, and unfair implementation that also does not perform runtime ownership error checking. In most cases this should be the mutual exclusion lock you will want to use. Consider using Rwlock in case most operations are reads.
val create : ?padded:bool -> unit -> tcreate () returns a new mutual exclusion lock that is initially unlocked.
Exception raised in case the lock has been poisoned.
val holding : t -> (unit -> 'a) -> 'aholding lock thunk acquires the lock and calls thunk (). In case thunk () returns a value, the lock is released and the value is returned. Otherwise the lock is poisoned and the exception is reraised.
The implementation of holding in terms of the low level operations is equivalent to:
let holding t thunk =
Lock.acquire t;
match thunk () with
| value ->
Lock.release t;
value
| exception exn ->
let bt = Printexc.get_raw_backtrace () in
Lock.poison t;
Printexc.raise_with_backtrace exn btval protect : t -> (unit -> 'a) -> 'aprotect lock thunk acquires the lock, runs thunk (), and releases the lock after thunk () returns or raises.
module Condition : sig ... endA condition variable.
val is_locked : t -> boolis_locked lock determines whether the lock is currently held exclusively.
⚠️ The calls in this section must be matched correctly or the state of the lock may become corrupted.
val acquire : t -> unitacquire lock acquires the lock exlusively.
val try_acquire : t -> booltry_acquire lock attempts to acquire the lock exclusively. Returns true in case of success and false in case of failure.
val release : t -> unitrelease lock releases the lock or does nothing in case the lock has been poisoned.
val poison : t -> unitpoison lock marks an exclusively held lock as poisoned.