package containers
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=03b80e963186e91ddac62ef645bf7fb2
sha512=c8f434808be540c16926bf03d89f394d33fc2d092f963a7b6d412481229e0a96290f1ad7c7d522415115d35426b7aa0b3fda4b991ddc321dad279d402c9a0c0b
doc/containers.thread/CCLock/index.html
Module CCLockSource
Utils around Mutex
A value wrapped into a Mutex, for more safety.
A value surrounded with a lock
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.
try_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.
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.
update l f replaces the content x of l with f x, atomically.
update_map l f computes x', y = f (get l), then puts x' in l and returns y.
Atomically get the value in the lock. The value that is returned isn't protected!