lifeguard
Object Pool Manager
lifeguard issues owned values wrapped in smartpointers.
extern crate lifeguard;
use Pool;
//...
let pool : = with_size;
// Values that have gone out of scope are automatically moved back into the pool.
assert_eq!;
Values taken from the pool can be dereferenced to access/mutate their contents.
extern crate lifeguard;
use Pool;
//...
let mut pool : = with_size;
let mut string = pool.new_from;
.push_str;
assert_eq!;
Values can be unwrapped, detaching them from the pool.
let mut pool : = with_size;
// The String goes out of scope and is dropped; it is not returned to the pool
assert_eq!;
Values can be manually entered into / returned to the pool.
let mut pool : = with_size;
// The String is owned by the pool now
assert_eq!;
Benchmarks
Current benchmarks show speedups between 20 and 40% depending on how much of the task at hand involves pure allocation; this should likely be more dramatic. Ideas and PRs welcome!
Inspired by frankmcsherry's recycler.