| Crates.io | dark-std |
| lib.rs | dark-std |
| version | 0.2.16 |
| created_at | 2022-03-07 11:59:00.075527+00 |
| updated_at | 2024-07-07 09:26:56.73176+00 |
| description | dark-std is an Implementation of asynchronous containers build on tokio. It uses a read-write separation design borrowed from Golang |
| homepage | |
| repository | https://github.com/darkrpc/dark-std.git |
| max_upload_size | |
| id | 544998 |
| size | 85,329 |
dark-std is an Implementation of asynchronous
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");
}