Expand description
- An experimental thread access synchronization primitive
- which is based on CoW Copy-on-Write and also exclusive lock.
- By default an RwLock based implementation is used, because the
- atomics based implementation is still not ready. It can be activated
- by enabling the feature prefer_atomic.
- The
ICoWRead<DATA>instance with inner valueDATAobtained from the ICoW<DATA>is valid even after the inner value was copied and copy was- commited back. All
readerswhich will will read theICoWinstance after - the
commitwill receive aICoWRead<DATA>with updatedDATA. - Exclusive copying prevents
readersfrom reading while simplenon-exclusive - copy allows to access the inner data for reading and further copying. But, the
non-exclusivecopies are not in sync, so each copy is uniq. Thesequential- commit of copied data is not yet supported.
-
ⓘ
let val = ICoW::new(TestStruct::new(1, 2)); // read only let read1 = val.read(); //.. drop(read1); // ... // copy on write NON-exclusively, read is possible let mut transaction = val.clone_copy(); transaction.start = 5; transaction.stop = 6; // update, after calling this function, all reades who // read before will still see old version. // all reades after, new transaction.commit(); //or drop(transaction); // to drop changes // exclusive lock, read is also not possible let res = val.clone_exclusivly(); // .. // commit changes releasing lock commit(val); //or drop(val); // to drop changes and release lock
Re-exports§
pub use cow_mutex::ICoW;pub use cow_mutex::ICoWRead;pub use cow_mutex::ICoWCopy;pub use cow_mutex::ICoWLock;
Modules§
- cow_
mutex - A RwLock based copy-on-write.
Enums§
- ICoW
Error - Errors which may be returned.
- ICoW
Lock Types - Type of the sync code.