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.
This PR changes the
Pool::create
method to return aRefMut
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 toPool::get
with that value's key will returnNone
while aRefMut
exists. TheRefMut
guard may be downgraded to an immutableRef
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 aRefMut
, rather than taking a closure and returning a key.Renamed
PoolGuard
topool::Ref
.