#container #tokio #wait-group #async #btree-map #vec #read-write

dark-std

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

7 releases

0.2.11 Mar 15, 2024
0.2.9 Dec 11, 2023
0.2.8 Oct 27, 2023
0.2.7 Jul 21, 2023
0.1.2 Mar 13, 2022

#116 in Asynchronous

Download history 890/week @ 2023-12-14 907/week @ 2023-12-21 788/week @ 2023-12-28 729/week @ 2024-01-04 872/week @ 2024-01-11 741/week @ 2024-01-18 955/week @ 2024-01-25 504/week @ 2024-02-01 431/week @ 2024-02-08 750/week @ 2024-02-15 1167/week @ 2024-02-22 1370/week @ 2024-02-29 1013/week @ 2024-03-07 1359/week @ 2024-03-14 1083/week @ 2024-03-21 723/week @ 2024-03-28

4,398 downloads per month
Used in 28 crates (5 directly)

MIT/Apache

49KB
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

~0.7–7.5MB
~26K SLoC