package containers

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Utils around Mutex

  • since 0.8
type 'a t

A value surrounded with a lock

val create : 'a -> 'a t

Create a new protected value

val with_lock : 'a t -> ('a -> 'b) -> 'b

with_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 update : 'a t -> ('a -> 'a) -> unit

update l f replaces the content x of l with f x, atomically

val mutex : _ t -> Mutex.t

Underlying mutex

val get : 'a t -> 'a

Get the value in the lock. The value that is returned isn't protected!

OCaml

Innovation. Community. Security.