Expand description
§rylv-pool
Generic pooling with pluggable providers, extracted from rylv_utils.
PoolItemdefines how reusable values are reset.PoolProvidercontrols acquisition, returns, and prewarming.PoolProvider::Entrylets each provider choose its own ownership handle and routing context, with mutable access andStableDerefguarantees.PoolGuardreturns values automatically on drop and implementsStableDeref.FixedThreadLocalPool<T, N>provides fixed-capacity thread-local storage and lock-free returns from other threads.Nlimits retained entries, not active guards. Its static TLS key reference implementsPoolProviderdirectly.PoolErrorpreserves factory errors and captured unwind panic payloads.
Public types are imported from the crate root. FixedThreadLocalEntry is an
opaque associated type of the thread-local provider; its routing details remain
private. Storage internals and test inspection helpers are not part of the API.
The crate depends only on stable_deref_trait.
use rylv_pool::{FixedThreadLocalPool, FixedThreadLocalPoolGuard, PoolItem};
#[derive(Default)]
struct Scratch(Vec<u8>);
impl PoolItem for Scratch {
fn reset(&mut self) {
self.0.clear();
}
}
thread_local! {
static POOL: FixedThreadLocalPool<Scratch, 8> = FixedThreadLocalPool::new();
}
let mut scratch = FixedThreadLocalPoolGuard::acquire(&POOL)?;
scratch.0.extend_from_slice(b"reusable storage");§Testing and CI
CI includes stable and MSRV builds on Linux/macOS/Windows, debug/release tests, Clippy, formatting, documentation, coverage artifacts, Miri, fuzzing, dependency security and license checks, semver checks, and tag-driven releases.
The coverage gate requires at least 95% of production lines. See CI setup for commands, artifacts, and required GitHub configuration, and test coverage map for the scenarios.
make verify runs the normal local checks. make coverage, make miri, and
make fuzz opt into the additional tools. cargo test --locked runs the root
crate’s unit, integration, and documentation tests.
§Benchmarks
make bench runs Criterion benchmarks in the optimized bench profile. Criterion
is a development dependency. They cover local reuse, misses, prewarming, remote
returns, and draining, with small values and reusable buffers. For example:
make bench BENCH_ARGS='warm/ --sample-size 50 --measurement-time 3'
make bench BENCH_ARGS='--list'See benchmark methodology for the scenarios, timing units, and comparison limits. Normal tests run the scenarios as smoke checks without reporting timings. Pull-request CI compares baselines with critcmp and fails on mean slowdowns greater than 15%; the threshold is configurable.
§License
Licensed under either Apache License 2.0 or MIT license, at your option.
Structs§
- Fixed
Thread Local Pool - Per-thread pool with capacity
Nfixed at compile time. - Panic
Error - The original payload of a captured unwind panic.
- Pool
Guard - Exclusive, address-stable guard returned by a
PoolProvider.
Enums§
- Pool
Error - A factory failure or an unwinding panic during a pool operation.
Traits§
- Pool
Item - A reusable value managed by a pool.
- Pool
Provider - Supplies complete take, return, and warming operations for a pool.
Type Aliases§
- Fixed
Thread Local Pool Guard - Guard using a consumer-defined thread-local pool key as its provider.