package batteries
Install
Dune Dependency
Authors
Maintainers
Sources
md5=d02c4f044e53edca010de46f9139ce00
sha512=99a5afa3604c4cf0c849c670111d617f7f255acb0da043b73ddffdf0e299948bce52516ee31921f269de6088156c4e0a187e0b931543c6819c6b25966b303281
doc/batteries.unthreaded/BatConcurrent/index.html
Module BatConcurrent
Source
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.
Create a lock from a pair of locking/unlocking functions
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
.
Specialized version of synchronized
.
sync lock f
behaves as synchronize (const lock) f
but slightly faster