Crate mempool

Source
Expand description

This crate provides a fast thread safe memory pool for reusing allocations. It aggressively optimizes for the single-threaded use case, but gracefully supports access from multiple threads simultaneously. In particular, values in a pool may not be shared across threads.

§Example

A pool takes an initialization function for creating members of the pool. Once created, values can be immediately retrieved.

use mempool::Pool;

let pool = Pool::new(Box::new(|| "foobar"));
assert_eq!("foobar", *pool.get());

Note that the pool returns an immutable reference. If you need a mutable reference, then use a RefCell. (Which is guaranteed safe by the pool.)

Structs§

  • A fast memory pool.

Type Aliases§

  • The type of an initialization function.