4 个稳定版本
1.1.0 | 2020 年 3 月 13 日 |
---|---|
1.0.2 | 2020 年 3 月 12 日 |
1076 在 并发 中排名
每月 下载 21 次
12KB
292 行
waitmap
Wait Map 是一个作为并发哈希表实现的异步/await 并发原语。它是基于 [dashmap][dashmap] 并发哈希表构建的,并添加了“等待”API。
“等待”API 允许用户等待一个任务,直到另一个任务填充了条目。例如
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 {
// ...
}
它还支持取消 API,以停止任何等待条目被填充的任务(future 评估为 None,就像它们调用了 get
且键为空一样)
// This will cause the other task to stop waiting, it receives a `None` value:
map.cancel("Rosa Luxemburg");
依赖关系
~420KB