#vec #wait-group #async #tokio #golang #borrowing #defer #read-write-separation #atomic-duration #std-sync

dark-std

dark-std is an Implementation of asynchronous containers build on tokio. It uses a read-write separation design borrowed from Golang

4 releases

0.2.16 Jul 7, 2024
0.2.14 May 3, 2024
0.2.11 Mar 15, 2024
0.2.9 Dec 11, 2023
0.1.2 Mar 13, 2022

#390 in Asynchronous

Download history 679/week @ 2026-01-08 1122/week @ 2026-01-15 1017/week @ 2026-01-22 997/week @ 2026-01-29 1039/week @ 2026-02-05 814/week @ 2026-02-12 1385/week @ 2026-02-19 1230/week @ 2026-02-26 1326/week @ 2026-03-05 1750/week @ 2026-03-12 1536/week @ 2026-03-19 1509/week @ 2026-03-26 1194/week @ 2026-04-02 1488/week @ 2026-04-09 1382/week @ 2026-04-16 1044/week @ 2026-04-23

5,335 downloads per month
Used in 50 crates (6 directly)

MIT/Apache

51KB
1.5K SLoC

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:

    #[tokio::test]
    pub async fn test_get() {
        let m = SyncHashMap::<i32, i32>::new();
        let insert = m.insert(1, 2);
        
        let g = m.get(&1).unwrap();//don't need lock and await
        assert_eq!(&2, g);
    }

wait group:

use std::time::Duration;
use tokio::time::sleep;
use dark_std::sync::WaitGroup;
#[tokio::test]
async fn test_wg() {
    let wg = WaitGroup::new();
    let wg2 = wg.clone();
    tokio::spawn(async move {
        sleep(Duration::from_secs(1)).await;
        drop(wg2);
    });
    let wg2 = wg.clone();
    tokio::spawn(async move {
        sleep(Duration::from_secs(1)).await;
        drop(wg2);
    });
    wg.wait_async().await;
    println!("all done");
}

Dependencies

~1.4–2.1MB
~39K SLoC