https://github.com/darkrpc/dark-std
an Implementation of asynchronous containers build on tokio. It uses a read-write separation design borrowed from Golang
https://github.com/darkrpc/dark-std
async syncmap
Last synced: 19 days ago
JSON representation
an Implementation of asynchronous containers build on tokio. It uses a read-write separation design borrowed from Golang
- Host: GitHub
- URL: https://github.com/darkrpc/dark-std
- Owner: darkrpc
- License: apache-2.0
- Created: 2022-03-07T08:41:33.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-12-20T08:25:32.000Z (4 months ago)
- Last Synced: 2025-12-22T14:47:59.804Z (4 months ago)
- Topics: async, syncmap
- Language: Rust
- Homepage:
- Size: 103 KB
- Stars: 9
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```rust
#[tokio::test]
pub async fn test_get() {
let m = SyncHashMap::::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:
```rust
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");
}
```