Tezos_stdlib.Lwt_rwlockA read-write lock for Lwt with writer priority.
This module provides a read-write lock that allows multiple concurrent readers or a single exclusive writer. Writers have priority: when a writer is waiting for the lock, new readers will block until the writer has acquired and released the lock.
Warning: this lock is not re-entrant. An Lwt thread that tries to acquire a lock it already holds can deadlock.
val create : unit -> tcreate () creates a new read-write lock.
val read_lock : t -> unit Lwt.tread_lock t acquires a read lock. Multiple readers can hold the lock concurrently. Blocks if a writer holds the lock or is waiting for it (writer priority).
val read_unlock : t -> unitread_unlock t releases a read lock.
val write_lock : t -> unit Lwt.twrite_lock t acquires an exclusive write lock. Blocks until all readers and any current writer release the lock. Has priority over new readers: once a writer starts waiting, new readers will block.
val write_unlock : t -> unitwrite_unlock t releases the write lock.
val with_read_lock : t -> (unit -> 'a Lwt.t) -> 'a Lwt.twith_read_lock t f executes f () while holding the read lock. The lock is released when f () completes, even if it raises an exception.
val with_write_lock : t -> (unit -> 'a Lwt.t) -> 'a Lwt.twith_write_lock t f executes f () while holding the write lock. The lock is released when f () completes, even if it raises an exception.