package balancer

  1. Overview
  2. Docs

Thread safe mutable that provides the gaurentees of a Multi Reader single Writer RW mutex, it handles locking and unlocking on it's own so you don't have to touch the mutex

type 'a t = {
  1. lock : Lwt_mutex.t;
  2. mutable value : 'a;
}
val read : 'a t -> 'a Lwt.t

Aquires a read lock and returns data

val value : 'a t -> 'a

Reads the inner value without a read lock for use in update and sync effect

val create : 'a -> 'a t
val become : 'a t -> 'a -> unit Lwt.t

Acquires write lock and sets value

val update : 'a t -> ('a -> 'a) -> 'a Lwt.t

Acquires write lock and applies f to it's contents

val sync : 'a t -> (unit -> 'b Lwt.t) -> 'b Lwt.t