dark-std
dark-std is an Implementation of asynchronous
- defer! (defer macro)
- SyncHashMap (async HashMap)
- SyncBtreeMap (async BtreeMap)
- SyncVec (async Vec)
- WaitGroup (async/blocking all support WaitGroup)
- AtomicDuration (atomic duration)
for example:
pub async
Synchronisation model (contention-free reads, locked writes): reads (
get/iter/dirty_ref/len/contains_key) never take a lock, never block and never contend with each other. Each thread registers a reader slot in its own private counter (per-thread QSBR-style); concurrent readers only touch their own cache line. Writes take a mutex, raise awritingflag and wait until every thread's reader counter is zero before mutating the container in place — O(1)/O(log n), no whole-container copy and noClonerequirement onK/V. The counters useSeqCstordering to close the store-buffering window, so a reader can never read while a writer mutates (verified with Miri against issue #3 reproductions). A read guard makes writers wait until it is dropped, so drop it before calling a write method from the same scope:# use ; # let m = new; # m.insert; let g = m.get.unwrap; assert_eq!; drop; // release the reader slot before writing m.insert;
wait group:
use Duration;
use sleep;
use WaitGroup;
async