package batteries
Install
Dune Dependency
Authors
Maintainers
Sources
md5=e4b70d1a716f0aaba36f419f618d0a2e
sha512=a31f1f8cf2c7c3c6c757f3bfae98ff61bb32bab6a1f1e215937df42bcfa447aad41a37edb28d7bcecb88b3838ed8bd57142bcf8e2d28e09bb538055fd8a3b72d
doc/batteries.unthreaded/BatConcurrent/index.html
Module BatConcurrent
Definition of concurrency primitives.
The light-weight type of a lock, i.e. a construction which may be used to guarantee that a section will not be interrupted by another thread.
This light-weight type is independent of the underlying locking mechanism and can be used if you do not know whether your code will run with vmthreads, Posix threads, coThreads, etc.
val create : enter:(unit -> unit) -> leave:(unit -> unit) -> lock
Create a lock from a pair of locking/unlocking functions
val nolock : lock
A lock which does nothing.
val synchronize : (unit -> lock) -> ('a -> 'b) -> 'a -> 'b
synchronize locker f
returns a function f'
which behaves as f
but whose executions are protected by one lock obtained from locker
. The same lock will be reused for all subsequent uses of f'
.
For instance, synchronize Mutex.make f
is a new function whose executions will by synchronized by a new lock. Conversely, synchronize (const my_lock) f
is a new function whose executions will be synchronized by an existing lock my_lock
.
val sync : lock -> ('a -> 'b) -> 'a -> 'b
Specialized version of synchronized
.
sync lock f
behaves as synchronize (const lock) f
but slightly faster
module type BaseLock = sig ... end
A signature for modules which implement locking.
module type Lock = sig ... end