NapMap
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.
Example Usage
async
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}");
}