Module veryfast::pool [] [src]

A heap allocator that gives ownership of the value like a Box, but allocates in batches.

The Pool class creates a pool of memory to allocate objects on. If it runs out, it will allocate more memory but will not move the old values from their place.

It gives the option to allocate each object on a separate CPU cache line, increasing performance of multithreaded algorithms.

The Object class has exclusive ownership of the value contained within. When dropped, the owned object will be dropped as well. The memory, however, will be returned to the Pool it was allocated from to be available for other allocations.

Examples

use veryfast::pool::{Pool, Object};

let pool = Pool::new(true, 1000);

let var1 = pool.add(15i32);
let mut var2 = pool.add(7);
*var2 = *var1;
assert_eq!(*var1, *var2);

let mut vec = Vec::new();
for i in 0..10 {
    vec.push(pool.add(i));
}
for i in &vec {
    print!("{} ", **i);
}

Structs

Object

A pointer type that owns its content.

Pool

A fast heap-allocator. Allocates objects in a batch, but transfers the control to the Object