-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for mutable access #41
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Something to note is the number of guards we are exposing in the public API.
} | ||
} | ||
|
||
pub fn is_nonexistent(&self) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here as above.
Having gone through the changes I think you got the main parts all done. I've got one thought though. I think we can provide more granular error messages here. Now we have multiple failure conditions for why a
As a user, I'd like to know which of these three cases caused the failure. I see that you already created a user facing error type EDIT: Or we can rename |
Besides that, I think it's mostly just tests and docs. |
@hawkw Added tests for the slab impl and looks like you had already created tests for the pool impl. Also added documentation. I figured I could port the |
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Co-authored-by: Bhargav <bIgBV@users.noreply.github.com>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
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`.
This is still quite rough, needs docs, additional testing, and cleanup, but it basically works.
Signed-off-by: Eliza Weisman eliza@buoyant.io