Skip to content

refactor(pool): borrow the pool during recycling - #347

Merged
tisonkun merged 2 commits into
mainfrom
codex/deslopify-pool-recycling
Oct 3, 2026
Merged

tisonkun merged 2 commits into
mainfrom
codex/deslopify-pool-recycling

Conversation

@tisonkun

@tisonkun tisonkun commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

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 from M::Object instead of carrying a redundant T parameter. Returned objects still hold a Weak and 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), and cargo x lint.

Follow-up to #345.

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.
@tisonkun
tisonkun merged commit d5e557d into main Oct 3, 2026
9 checks passed
@tisonkun
tisonkun deleted the codex/deslopify-pool-recycling branch October 3, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant