#对象池 # #异步池 #异步 #同步原语

dev async-object-pool

仅使用异步同步原语的简单对象池实现

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 异步

Download history 27833/week @ 2024-03-14 26712/week @ 2024-03-21 22575/week @ 2024-03-28 25461/week @ 2024-04-04 30838/week @ 2024-04-11 32458/week @ 2024-04-18 32662/week @ 2024-04-25 31174/week @ 2024-05-02 41079/week @ 2024-05-09 44572/week @ 2024-05-16 47581/week @ 2024-05-23 50528/week @ 2024-05-30 47251/week @ 2024-06-06 50327/week @ 2024-06-13 51439/week @ 2024-06-20 39883/week @ 2024-06-27

198,523 每月下载量
138 个crate中使用 (2 直接)

MIT 许可证

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