| Crates.io | napmap |
| lib.rs | napmap |
| version | 0.1.2 |
| created_at | 2024-04-01 08:21:41.169974+00 |
| updated_at | 2024-06-15 18:58:53.268475+00 |
| description | Async HashMap that halts requester tasks until the requested data is accessible |
| homepage | |
| repository | https://github.com/Ghamza-Jd/napmap |
| max_upload_size | |
| id | 1192314 |
| size | 18,278 |
NapMap is an async HashMap that halts requester tasks until the requested data is accessible.
Fundementally it's a syncronization tool between tasks, were tasks can write on to the map and other can read from it.
#[tokio::main]
async fn main() {
let napmap = Arc::new(UnboundedNapMap::new());
tokio::spawn({
let map = napmap.clone();
async move {
tokio::time::sleep(Duration::from_secs(2)).await;
map.insert("key", 7).await;
}
});
let value = napmap.get("key").await.unwrap();
println!("value: {value}");
}