pub trait Poolable {
type Data: Clearable + Send + 'static;
// Required method
fn from_data(
strategy: Arc<dyn ReclaimStrategy<Self> + Send + Sync>,
data: Self::Data,
) -> Self;
}
Expand description
An item that is poolable.
This meta-trait is used to mark a type as being poolable, where the type itself wraps a piece of data (Self::Data), and the data itself is the actual value which gets pooled and reused.
While somewhat incestuous, what this unlocks is the ability to use wrapping types to hide away the complexity of
ensuring that data which is given from an objext pool is eventully returned and not lost. Otherwise, trying to do
something like using drop logic to send T
back to an object pool would involve replacing the value of T
with a
new value, which is not always possible, at least not without incurring additional allocations, which would negate
the use of an object pool in the first place.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.