package balancer

  1. Overview
  2. Docs

Module Util.SyncVarSource

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

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

Aquires a read lock and returns data

Sourceval value : 'a t -> 'a

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

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

Acquires write lock and sets value

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

Acquires write lock and applies f to it's contents

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