2 unstable releases

Uses old Rust 2015

0.2.0 Aug 29, 2016
0.1.0 Aug 25, 2016

#39 in #object-pool

Download history 5/week @ 2024-07-22 7/week @ 2024-07-29 35/week @ 2024-08-05 58/week @ 2024-08-12 31/week @ 2024-08-19 32/week @ 2024-08-26 27/week @ 2024-09-02 54/week @ 2024-09-09 113/week @ 2024-09-16 49/week @ 2024-09-23 48/week @ 2024-09-30 63/week @ 2024-10-07 25/week @ 2024-10-14 78/week @ 2024-10-21 54/week @ 2024-10-28 82/week @ 2024-11-04

241 downloads per month
Used in 3 crates (2 directly)

MIT license

9KB
228 lines

objpool

Thread-safe generic object pool

Build Status Coverage Status

Examples

use objpool::Pool;
use std::thread;

let pool = Pool::with_capacity(5, || 0);
let mut handles = Vec::new();
for _ in 0..10 {
    let pool = pool.clone();
    handles.push(thread::spawn(move || {
        for _ in 0..1000 {
            *pool.get() += 1;
        }
    }));
}

for handle in handles {
    handle.join().unwrap();
}
assert_eq!(*pool.get() + *pool.get() + *pool.get() + *pool.get() + *pool.get(), 10000);

lib.rs:

Examples

use objpool::Pool;
use std::thread;

let pool = Pool::with_capacity(5, || 0);
let mut handles = Vec::new();
for _ in 0..10 {
    let pool = pool.clone();
    handles.push(thread::spawn(move || {
        for _ in 0..1000 {
            *pool.get() += 1;
        }
    }));
}

for handle in handles {
    handle.join().unwrap();
}
assert_eq!(*pool.get() + *pool.get() + *pool.get() + *pool.get() + *pool.get(), 10000);

No runtime deps