#hash-map #async

napmap

Async HashMap that halts requester tasks until the requested data is accessible

1 unstable release

0.1.1 Apr 1, 2024

#445 in Asynchronous

Download history 191/week @ 2024-03-30 48/week @ 2024-04-06 1/week @ 2024-04-13 4/week @ 2024-04-20

244 downloads per month
Used in 2 crates (via jarust)

MIT license

12KB
275 lines

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}");
}

Dependencies

~3–4.5MB
~66K SLoC