Module cow_mutex

Module cow_mutex 

Source
Expand description

A RwLock based copy-on-write.

Structsยง

ICoW
A main structure which implements CoW approach based on RwLock for the multithreading syncing. The object stored inside can be read directly, but modifying the inner value is performed using CoW copy-on-write approach.
ICoWCopy
A write-guard which holds new value to which the new values are written. And previous value too. This type of guard is not exclusive, so it does not prevent multiple CoW operations. Normally, if some object which may be written simultaniously i.e lost connection to remote server and reconnect is required, the exclusive lock would be more desirable.
ICoWLock
A write-guard which holds new value to which the new values are written. And previous value too. This type of guard is exclusive, so multiple CoW operations CANNOT be performed in parallel which is good for instance update without racing. The readers are also waiting until the changes are commited.
ICoWRead
A read only guard. Implements Deref only. The guarded value is valid all the time, even if the inner value was updated. The updated value will not be visible in the current instance until re-read is performed.