package containers-thread
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=6d29c36329a02608531babb11e08b6f4
sha512=ebf4c682bc43ed344edbbcfd40777d829cd0cb85a9b1381e38a89e4d9567dc6e1207667716eeb78140774a5ac49132f3f29a14f037147ed64a8952eec75aa6c8
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!