dark-std 0.2.20

Thread-safe containers with a read-write separation design borrowed from Golang: reads avoid the container write-lock and never contend with each other; writes are serialized and wait for active readers. Plus async/blocking utilities
Documentation
//! Regression tests for https://github.com/darkrpc/dark-std/issues/3
//!
//! These are the exact single-access reproductions from the issue. Previously
//! `get`/`dirty_ref` returned plain references into the shared storage without
//! any synchronisation, so running these under Miri reported data races. All
//! access is now synchronised (per-thread reader slots + writer waits), so
//! these run race-free.

use dark_std::sync::{SyncBtreeMap, SyncHashMap, SyncIndexMap, SyncVec};

#[test]
fn sync_btree_map_race() {
    let map: SyncBtreeMap<bool, bool> = SyncBtreeMap::new();
    map.insert(true, true);
    std::thread::scope(|s| {
        s.spawn(|| {
            map.dirty_ref();
        });
        map.remove(&true);
    });
}

#[test]
fn sync_hash_map_race() {
    let map: SyncHashMap<bool, bool> = SyncHashMap::new();
    std::thread::scope(|s| {
        s.spawn(|| {
            map.get(&true);
        });
        map.insert(true, true);
    });
}

#[test]
fn sync_vec_race() {
    let vec: SyncVec<bool> = SyncVec::new();
    vec.push(true);
    std::thread::scope(|s| {
        s.spawn(|| {
            vec.get(0);
        });
        vec.push(false);
    });
}

#[test]
fn sync_index_map_race() {
    let map: SyncIndexMap<bool, bool> = SyncIndexMap::new();
    std::thread::scope(|s| {
        s.spawn(|| {
            map.dirty_ref();
        });
        map.insert(true, true);
    });
}