7个版本
0.1.4 | 2021年1月7日 |
---|---|
0.1.3 | 2020年11月14日 |
0.1.2 | 2020年11月14日 |
0.1.1 | 2020年11月14日 |
0.1.0 | 2020年11月14日 |
#922 in 异步
198,523 每月下载量
在 138 个crate中使用 (2 直接)
6KB
async-object-pool
仅使用异步同步原语的简单对象池实现。
你可以这样使用它
use async_object_pool::Pool;
// Create a new pool that will allow to create at most 100 items
let pool = Pool::new(100);
// Take an item from the pool or create a new item if the pool is empty
// but the maximum number of pooled items was not created yet.
// This will asynchronously block execution until an item can be returned.
let item = pool.take_or_create(|| String::from("hello")).await;
// Use your item
println!("{}", item);
// After using the item, put it back into the pool so it can be reused elsewhere
pool.put(item).await;
此crate用于在httpmock中池化HTTP模拟服务器。
许可证
async-object-pool
是免费软件:你可以在MIT公共许可证的条款下重新分发它并/或修改它。
此程序的分发是为了希望它将是有用的,但没有任何保证;甚至没有关于适销性或适用于特定目的的暗示性保证。有关更多详细信息,请参阅MIT公共许可证。
依赖关系
~5–14MB
~168K SLoC