napmap

Crates.ionapmap
lib.rsnapmap
version0.1.2
sourcesrc
created_at2024-04-01 08:21:41.169974
updated_at2024-06-15 18:58:53.268475
descriptionAsync HashMap that halts requester tasks until the requested data is accessible
homepage
repositoryhttps://github.com/Ghamza-Jd/napmap
max_upload_size
id1192314
size18,278
Hamza Jadid (Ghamza-Jd)

documentation

README

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

#[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}");
}
Commit count: 7

cargo fmt