Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fastpool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
name = "fastpool"

description = "This crates implements a fast object pool for Async Rust."
version = "0.4.2"
version = "1.0.0"

edition.workspace = true
homepage.workspace = true
Expand Down
11 changes: 9 additions & 2 deletions fastpool/src/bounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,16 @@ impl<M: ManageObject> Pool<M> {
})
}

/// Replenishes the pool with at most `most` number of new objects.
/// Replenishes the pool with at most `most` number of new objects:
///
/// Returns the number of objects that are actually replenished to the pool.
/// 1. If the pool has fewer slots to fill than `most`, narrow `most` to the number of slots.
/// 2. If there is already any idle object in the pool, decrease `most` by the number of idle
/// objects.
/// 3. If [`ManageObject::create`] returns `Err`, reduces `most` by 1 and continues to the next.
///
/// Returns the number of objects that are actually replenished to the pool. This method is
/// suitable to implement functionalities like minimal idle connections in a connection
/// pool.
pub async fn replenish(&self, most: usize) -> usize {
let mut permit = {
let mut n = most;
Expand Down
Loading