DoxigAlpha

initPreheated

Creates a new memory pool and pre-allocates initial_size items. This allows the up to initial_size active allocations before a OutOfMemory error happens when calling create().

Function parameters

Parameters

#
allocator:std.mem.Allocator
initial_size:usize

Type definitions in this namespace

Types

#

A memory pool that can allocate objects of a single type very quickly.

Functions

#
MemoryPool
A memory pool that can allocate objects of a single type very quickly.
MemoryPoolAligned
A memory pool that can allocate objects of a single type very quickly.
MemoryPoolExtra
A memory pool that can allocate objects of a single type very quickly.

Error sets in this namespace

Error Sets

#

Source

Implementation

#
pub fn initPreheated(allocator: std.mem.Allocator, initial_size: usize) MemoryPoolError!Pool {
    var pool = init(allocator);
    errdefer pool.deinit();
    try pool.preheat(initial_size);
    return pool;
}