rylv-pool 0.1.0

Generic pooling with pluggable providers and thread-local storage
Documentation
  • Coverage
  • 100%
    15 out of 15 items documented5 out of 5 items with examples
  • Size
  • Source code size: 180.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 332.3 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • rylv/rylv-pool
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • andresmargalef

rylv-pool

Generic pooling with pluggable providers, extracted from rylv_utils.

  • PoolItem defines how reusable values are reset.
  • PoolProvider controls acquisition, returns, and prewarming.
  • PoolProvider::Entry lets each provider choose its own ownership handle and routing context, with mutable access and StableDeref guarantees.
  • PoolGuard returns values automatically on drop and implements StableDeref.
  • FixedThreadLocalPool<T, N> provides fixed-capacity thread-local storage and lock-free returns from other threads. N limits retained entries, not active guards. Its static TLS key reference implements PoolProvider directly.
  • PoolError preserves 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");
# Ok::<(), rylv_pool::PoolError<std::convert::Infallible>>(())

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.