preheat
Preheats the memory pool by pre-allocating size items.
This allows up to size active allocations before an
OutOfMemory error might happen when calling create().
Function parameters
Parameters
- pool:*Pool
- 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 preheat(pool: *Pool, size: usize) MemoryPoolError!void {
var i: usize = 0;
while (i < size) : (i += 1) {
const raw_mem = try pool.allocNew();
const free_node = @as(NodePtr, @ptrCast(raw_mem));
free_node.* = Node{
.next = pool.free_list,
};
pool.free_list = free_node;
}
}