Crates.io | fast-able |
lib.rs | fast-able |
version | |
source | src |
created_at | 2023-06-03 14:34:18.905739 |
updated_at | 2024-12-06 04:37:29.485709 |
description | The world's martial arts are fast and unbreakable; 天下武功 唯快不破 |
homepage | |
repository | https://gitee.com/guoyucode/sync-data.git |
max_upload_size | |
id | 881680 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
sync-data is a high-performance synchronization library
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");
}