concurrent-pool-0.1.0 has been yanked.
concurrent-pool
A concurrent object pool based on Crossbeam Queue
Features
- Configurable capacity and preallocation.
- Thread-safe: Multiple threads can pull and recycle items concurrently.
- Automatic reclamation of unused item when the continuous occurrence
of
fast-pullreaches a certain threshold ifauto_reclaimis enabled.
fast-pull: After pulling data from the memory pool, available allocated
entities in the memory pool are exceed a certain threshold. We call this pull
is a fast-pull.
Examples
Local memory pool
use Pool;
let pool: = with_capacity;
assert_eq!;
let item = pool.pull.unwrap;
assert_eq!;
assert_eq!;
let item_clone = item.clone;
drop;
assert_eq!;
drop;
assert_eq!;
Multiple threads shared memory pool
use Pool;
use ;
let pool: = new;
let = channel;
let clone_pool = pool.clone;
let tx1 = tx.clone;
let sender1 = spawn;
let clone_pool = pool.clone;
let sender2 = spawn;
let receiver = spawn;
sender1.join.unwrap;
sender2.join.unwrap;
receiver.join.unwrap;
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.