Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Pool): change
Pool::create
to return a mutable guard (#48)
This PR changes the `Pool::create` method to return a `RefMut` guard, which allows mutable access to the new pooled item, rather than taking a closure that is used to initialize the item. A new method, `Pool::create_with`, provides the old behavior. When a slot is referenced by a `RefMut` guard, it may not be accessed by other threads. Calls to `Pool::get` with that value's key will return `None` while a `RefMut` exists. The `RefMut` guard may be downgraded to an immutable `Ref` guard, allowing other threads to access the pooled item while retaining a guard for immutably accessing it. Closes #41. Fixes #16. BREAKING CHANGE: Changed `Pool::create` to return a `RefMut`, rather than taking a closure and returning a key. Renamed `PoolGuard` to `pool::Ref`.
- Loading branch information
Showing
7 changed files
with
730 additions
and
221 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.