package containers
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=d84e09c5d0abc501aa17cd502e31a038
sha512=8b832f4ada6035e80d81be0cfb7bdffb695ec67d465ed6097a144019e2b8a8f909095e78019c3da2d8181cc3cd730cd48f7519e87d3162442562103b7f36aabb
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!