package containers-thread
Install
Dune Dependency
Authors
Maintainers
Sources
md5=8cd9d8ddf89a60d8f2b005163707ea0e
sha512=eaeaf87c20ef124b923e461ce108e97d368d5228dd737c83d78c53741e15a8d9bc2af97150efd266cb99c4af63a7a87de47a1c2f3c51725cf62fe4d53b46daa5
doc/containers-thread/CCLock/index.html
Module CCLock
Source
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!