A pinned object pool that contains any type of object as long as it has a compatible memory layout.
The pool returns super-powered pointers (Pooled<T>) that can be copied and cloned freely, providing type-safe access to the stored values.
use Layout;
use OpaquePool;
// Create a pool for storing values that match the layout of `u64`.
let layout = ;
let mut pool = builder.layout.build;
// Insert values into the pool.
// SAFETY: The layout of u64 matches the pool's item layout.
let pooled1 = unsafe ;
// SAFETY: The layout of u64 matches the pool's item layout.
let pooled2 = unsafe ;
// The handles act like super-powered pointers - they can be copied freely.
let pooled1_copy = pooled1;
// Read data back from the pooled items.
let value1 = unsafe ;
let value1_copy = unsafe ;
assert_eq!;
More details in the package documentation.
This is part of the Folo project that provides mechanisms for high-performance hardware-aware programming in Rust.