#object-pool #recycle

macro poolshark_derive

Thread safe object pool

2 releases

Uses new Rust 2024

0.1.1 Sep 5, 2025
0.1.0 Aug 30, 2025

#10 in #recycle

Download history 131/week @ 2025-08-27 161/week @ 2025-09-03 30/week @ 2025-09-10 53/week @ 2025-09-17 53/week @ 2025-09-24 61/week @ 2025-10-01

208 downloads per month
Used in 18 crates (via poolshark)

MIT license

7KB
127 lines

Thead Safe Object Pool

This is a general purpose thread safe object pool that supports most data structures in the standard library, as well as many useful external data structures such as IndexMap, triomphe::Arc, etc.

It limits the pool size as well as the element size to prevent memory waste.

use std::sync::LazyLock;
use poolshark::Pool;

static POOL: LazyLock<Pool<Vec<String>>> = LazyLock::new(|| Pool::new(1024, 1024))

fn main() {
    let mut v = POOL.take();
    // do stuff with v
    drop(v) // v actually goes back into the pool
}

Dependencies

~160–570KB
~14K SLoC