Module Rwlock.Shared_guard

type 'k t

'k Rwlock.Shared_guard.t represents a reader-writer locked that is locked non-exclusively for reading. It morally contains a Capsule.Key.t @@ aliased, but also has a finalizer that freezes the lock if the guard is garbage collected without being passed to Shared_guard.release.

val with_key : 'a 'k. 'k t @ unique -> (f:('k Capsule.Key.t -> 'a @ unique once) @ local once -> 'a * 'k t @ unique once) @ once

with_key guard ~f runs f, providing it an aliased key for 'k, and returns the result of f together with the read guard.

val with_password : 'a 'k. 'k t @ unique -> (f:('k Capsule.Password.Shared.t @ local -> 'a @ unique) @ local once -> 'a * 'k t @ unique) @ once

with_password g ~f runs f, providing it a shared password for 'k, and returns the result of f together with the guard.

val access : 'a 'k. 'k t @ unique -> (f: ('k Capsule.Access.t @ shared -> 'a @ unique once portable contended) @ local once portable -> 'a * 'k t @ unique once portable contended) @ once

access g ~f runs f, providing it shared access to the capsule 'k, and returns the result of f together with the guard.

val release : 'k t @ unique -> unit

release guard releases the read lock

val freeze : 'k t @ unique -> 'k Capsule.Key.t

freeze guard marks the lock protected by the read guard guard as frozen, preventing later attempts to acquire it for writing, and returns an aliased key to the capsule.