Struct veryfast::pool::Pool [] [src]

pub struct Pool<T> { /* fields omitted */ }

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

Allocations will first check if there is an already free slot to use, and use that. If no, It will take a lock and allocate a batch of memory.

When objects are dropped, their memory will be returned to the pool to be used again later. The memory of the batches will be deallocated only when the Pool and all the related Objects are dropped.

Methods

impl<T> Pool<T>
[src]

[src]

Creates a new Pool.

[src]

Creates a new Pool.

  • align_to_cache: Should each object be on a separate CPU cache line. Speeds up multithreaded usage, but hurts single-threaded cache locality a bit and requires a bit more memory. Has no effect if size_of::<T> is already a multiple of a cache line size.

[src]

Creates a new Pool.

  • align_to_cache: Should each object be on a separate CPU cache line. Speeds up multithreaded usage, but hurts single-threaded cache locality a bit and requires a bit more memory. Has no effect if size_of::<T> is already a multiple of a cache line size.

  • cache_line_size: The size of an L1 cache line on the architecture. Must be a power of 2.

  • number_of_sets: The number of associativity sets of the target processor. Decides the size of batch allocations.

[src]

Save the object on the heap. Will get a pointer that will drop it's content when dropped (like a Box). The memory will be reused though!

Thread-safe. Very fast most of the time, but will take a bit longer if need to allocate more objects.

Will panic if out of memory.

Trait Implementations

impl<T> Default for Pool<T>
[src]

[src]

Returns the "default value" for a type. Read more

impl<T> Drop for Pool<T>
[src]

[src]

Executes the destructor for this type. Read more

impl<T: Send> Send for Pool<T>
[src]

impl<T: Send> Sync for Pool<T>
[src]

impl<T> Debug for Pool<T>
[src]

[src]

Formats the value using the given formatter.