package batteries

  1. Overview
  2. Docs
A community-maintained standard library extension

Install

Dune Dependency

Authors

Maintainers

Sources

v3.9.0.tar.gz
md5=ea26b5c72e6731e59d856626049cca4d
sha512=55975b62c26f6db77433a3ac31f97af609fc6789bb62ac38b267249c78fd44ff37fe81901f1cf560857b9493a6046dd37b0d1c0234c66bd59e52843aac3ce6cb

doc/batteries.unthreaded/BatConcurrent/index.html

Module BatConcurrentSource

Definition of concurrency primitives.

  • author David Teller
Sourcetype lock

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.

Sourceval create : enter:(unit -> unit) -> leave:(unit -> unit) -> lock

Create a lock from a pair of locking/unlocking functions

  • parameter enter

    Enter critical section.

  • parameter leave

    Leave critical section. .

Sourceval nolock : lock

A lock which does nothing.

Sourceval 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.

Sourceval sync : lock -> ('a -> 'b) -> 'a -> 'b

Specialized version of synchronized.

sync lock f behaves as synchronize (const lock) f but slightly faster

Sourceval compose : lock -> lock -> lock

Compose two lock systems into a third lock system.

Sourcemodule type BaseLock = sig ... end

A signature for modules which implement locking.

Sourcemodule type Lock = sig ... end
Sourcemodule MakeLock (M : BaseLock) : Lock with type t = M.t
OCaml

Innovation. Community. Security.