CCLockA value wrapped into a Mutex, for more safety.
val create : 'a -> 'a tCreate a new protected value.
val 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 released.
val try_with_lock : 'a t -> ('a -> 'b) -> 'b optiontry_with_lock l f runs f x in a critical section if l is not locked. x is the value protected by the lock l. If f x fails, try_with_lock l f fails too but the lock is released.
module LockRef : sig ... endType allowing to manipulate the lock as a reference.
with_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 call.
val update : 'a t -> ('a -> 'a) -> unitupdate l f replaces the content x of l with f x, atomically.
val update_map : 'a t -> ('a -> 'a * 'b) -> 'bupdate_map l f computes x', y = f (get l), then puts x' in l and returns y.
val get : 'a t -> 'aAtomically get the value in the lock. The value that is returned isn't protected!
val set : 'a t -> 'a -> unitAtomically set the value.
val incr : int t -> unitAtomically increment the value.
val decr : int t -> unitAtomically decrement the value.
val incr_then_get : int t -> intincr_then_get x increments x, and returns its new value.
val get_then_incr : int t -> intget_then_incr x increments x, and returns its previous value.
val decr_then_get : int t -> intdecr_then_get x decrements x, and returns its new value.
val get_then_decr : int t -> intget_then_decr x decrements x, and returns its previous value.
val get_then_set : bool t -> boolget_then_set b sets b to true, and returns the old value.
val get_then_clear : bool t -> boolget_then_clear b sets b to false, and returns the old value.