refactor(pool): borrow the pool during recycling - #347
Merged
Merged
Conversation
UnreadyObject only lives inside Pool::get, which already borrows an Arc<Pool>. Hold that borrow directly, remove the copied cancellation policy, and stop upgrading a Weak that cannot have expired. Create the returned Object's Weak in ready(), preserving independent checkout lifetimes. Cover both pool variants when a recycled object outlives its pool and is then dropped or detached.
UnreadyObject is private and its object type is fixed by ManageObject. Use M::Object directly instead of carrying T and repeating Object = T bounds across the guard and its implementations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Both recycling guards live inside
Pool::get, which borrows the pool throughout validation and cancellation cleanup. Store that borrow directly, removing redundant weak-reference upgrades and the copied cancellation strategy. The unbounded guard derives its object type fromM::Objectinstead of carrying a redundantTparameter. Returned objects still hold aWeakand can outlive the pool.Add a shared lifecycle test for both pool variants: a recycled object remains usable after the pool is destroyed, and dropping or detaching it does not invoke a dead pool's hook. Existing tests cover both cancellation policies and rejected recycling.
Validation:
cargo x test(618 passed),cargo x check(26 feature configurations), andcargo x lint.Follow-up to #345.