objpool

Crates.ioobjpool
lib.rsobjpool
version0.2.0
sourcesrc
created_at2016-08-25 23:42:26.112739
updated_at2016-08-29 01:39:47.626357
descriptionThread-safe generic object pool
homepage
repositoryhttps://github.com/btmorex/objpool
max_upload_size
id6116
size11,427
Avery Fay (btmorex)

documentation

https://btmorex.github.io/objpool/objpool/index.html

README

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);
Commit count: 28

cargo fmt