• Stars
    star
    116
  • Rank 303,894 (Top 6 %)
  • Language
    Rust
  • Created over 4 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

waitmap

waitmap version

Wait Map is an async/await concurrency primitive implemented as a concurrent hashmap. It is built on top of the dashmap concurrent hashmap, with an additional "wait" API.

The wait API lets users wait on one task for an entry to be filled by another task. For example:

let map: WaitMap<String, Value>;

// This will wait until a value is put under the key "Rosa Luxemburg"
if let Some(value) = map.wait("Rosa Luxemburg").await {
    // ...
}

It also supports a cancellation API, to cause any task waiting on an entry being filled to stop waiting (the future evaluating to None, just as if they had called get and the key was empty):

// This will cause the other task to stop waiting, it receives a `None` value:
map.cancel("Rosa Luxemburg");