#wait-group #able #vec #btree-map #hash-map #fast-able #唯快不破 #sync-data

bin+lib fast-able

The world's martial arts are fast and unbreakable; 天下武功 唯快不破

120 stable releases

new 1.17.6 Apr 27, 2025
1.15.8 Mar 12, 2025
1.13.26 Dec 6, 2024
1.13.21 Nov 28, 2024
0.1.1 Jun 3, 2023

#5 in #wait-group

Download history 99/week @ 2025-01-05 51/week @ 2025-01-12 6/week @ 2025-01-19 6/week @ 2025-02-02 105/week @ 2025-02-09 1484/week @ 2025-02-16 66/week @ 2025-02-23 451/week @ 2025-03-02 679/week @ 2025-03-09 116/week @ 2025-03-16 7/week @ 2025-03-23 1/week @ 2025-03-30 880/week @ 2025-04-13 287/week @ 2025-04-20

1,174 downloads per month
Used in 2 crates

MIT/Apache

210KB
5K SLoC

sync-data

sync-data is a high-performance synchronization library

  • SyncHashMap (sync HashMap)
  • SyncBtreeMap (sync BtreeMap)
  • SyncVec (sync Vec)
  • WaitGroup (async/blocking all support WaitGroup)

for example:

    pub static RECKON_BY_SEC: once_cell::sync::Lazy<Statis> =
    once_cell::sync::Lazy::new(|| Statis::new(|v| println!("one sec run sum: {v}")));

// one sec run sum: 2347872
#[test]
fn bench_insert_mul_thread() {
    // common_uu::log4rs_mod::init().unwrap();
    let rw = Arc::new(SyncHashMap::new(Some(10)));
    rw.insert(1, 1);
    assert_eq!(rw.len(), 1);

    let rw2 = rw.clone();
    let rt1 = std::thread::spawn(move || {
        for i in 0..5_0000_0000_u64 {
            rw2.insert(i, i + 1);
            RECKON_BY_SEC.add();
        }
    });

    let rw2 = rw.clone();
    let rt2 = std::thread::spawn(move || {
        for i in 5_0000_0000..10_0000_0000_u64 {
            rw2.insert(i, i + 1);
            RECKON_BY_SEC.add();
        }
    });

    let rw2 = rw.clone();
    let rt3 = std::thread::spawn(move || {
        for i in 10_0000_0000_u64..50_0000_0000_u64 {
            rw2.insert(i, i + 1);
            RECKON_BY_SEC.add();
        }
    });


    rt1.join();
}

wait group:

use std::time::Duration;
use tokio::time::sleep;
use fast_able::wg::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

~3–9MB
~79K SLoC