module CCLock:sig..end
A value wrapped into a Mutex, for more safety.
Since 0.8
type 'a t
val create : 'a -> 'a tval with_lock : 'a t -> ('a -> 'b) -> 'bwith_lock l f runs f x where x is the value protected with
the lock l, in a critical section. If f x fails, with_lock l f
fails too but the lock is releasedmodule LockRef:sig..end
val with_lock_as_ref : 'a t -> f:('a LockRef.t -> 'b) -> 'bwith_lock_as_ref l f calls f with a reference-like object
that allows to manipulate the value of l safely.
The object passed to f must not escape the function callval update : 'a t -> ('a -> 'a) -> unitupdate l f replaces the content x of l with f x, atomicallyval update_map : 'a t -> ('a -> 'a * 'b) -> 'bupdate_map l f computes x', y = f (get l), then puts x' in l
and returns yval mutex : 'a t -> Mutex.tval get : 'a t -> 'aval set : 'a t -> 'a -> unitval incr : int t -> unitval decr : int t -> unitval incr_then_get : int t -> intincr_then_get x increments x, and return its new valueval get_then_incr : int t -> intget_then_incr x increments x, and return its previous valueval decr_then_get : int t -> intdecr_then_get x decrements x, and return its new valueval get_then_decr : int t -> intget_then_decr x decrements x, and return its previous valueval get_then_set : bool t -> boolget_then_set b sets b to true, and return the old valueval get_then_clear : bool t -> boolget_then_clear b sets b to false, and return the old value