Veritable Lasagna
An Allocator & Data Structure Library for C.
Loading...
Searching...
No Matches
vl_async_pool.c File Reference
#include "vl_async_pool.h"
#include "vl_memory.h"
+ Include dependency graph for vl_async_pool.c:

Macros

#define VL_ASYNC_POOL_BLOCK_MIN   (1 << 4)
 
#define VL_ASYNC_POOL_BLOCK_MAX   (1 << 16)
 

Functions

void vlAsyncPoolInit (vl_async_pool *pool, vl_uint16_t elementSize)
 Initializes the specified async pool.
 
void vlAsyncPoolFree (vl_async_pool *pool)
 Frees the specified async pool, and all associated memory.
 
vl_async_poolvlAsyncPoolNew (vl_uint16_t elementSize)
 Allocates and initializes a new async pool.
 
void vlAsyncPoolDelete (vl_async_pool *pool)
 Deinitializes and deletes the specified async pool, and all associated memory.
 
void vlAsyncPoolReset (vl_async_pool *pool)
 Resets the specified async pool, returning it to its state when it was first initialized.
 
void vlAsyncPoolClear (vl_async_pool *pool)
 Resets the state of all blocks and the pool, retaining memory but invalidating taken elements.
 
void * vlAsyncPoolTake (vl_async_pool *pool)
 Takes an element from the specified async pool.
 
void vlAsyncPoolReturn (vl_async_pool *pool, void *element)
 Returns an element to the specified async pool.
 

Variables

const vl_ularge_t VL_ASYNC_POOL_BLOCK_ALIGNMENT = 32
 Byte-level alignment of individual vlAsyncPool memory blocks.
 
const vl_ularge_t VL_ASYNC_POOL_NODE_ALIGNMENT = 16
 Byte-level alignment of individual vlAsyncPool element nodes.
 

Macro Definition Documentation

◆ VL_ASYNC_POOL_BLOCK_MAX

#define VL_ASYNC_POOL_BLOCK_MAX   (1 << 16)

◆ VL_ASYNC_POOL_BLOCK_MIN

#define VL_ASYNC_POOL_BLOCK_MIN   (1 << 4)

Function Documentation

◆ vlAsyncPoolClear()

void vlAsyncPoolClear ( vl_async_pool * pool)

Resets the state of all blocks and the pool, retaining memory but invalidating taken elements.

This does not free any associated memory.

Warning
This will invalidate all elements taken prior to this call. Manual synchronization is highly recommended.
Parameters
poolpointer to the async pool to clear
+ Here is the caller graph for this function:

◆ vlAsyncPoolDelete()

void vlAsyncPoolDelete ( vl_async_pool * pool)

Deinitializes and deletes the specified async pool, and all associated memory.

The specified pool must have been initialized via vlAsyncPoolNew.

Warning
This will invalidate all elements taken prior to this call. Manual synchronization is highly recommended.
See also
vlAsyncPoolNew
Parameters
poolpointer to async pool to delete
+ Here is the call graph for this function:

◆ vlAsyncPoolFree()

void vlAsyncPoolFree ( vl_async_pool * pool)

Frees the specified async pool, and all associated memory.

The pool must have been initialized via vlAsyncPoolInit.

Warning
This will invalidate all elements taken prior to this call. Manual synchronization is highly recommended.
See also
vlAsyncPoolInit
Parameters
pool
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlAsyncPoolInit()

void vlAsyncPoolInit ( vl_async_pool * pool,
vl_uint16_t elementSize )

Initializes the specified async pool.

The pool must be later freed via vlAsyncPoolFree.

See also
vlAsyncPoolFree
Parameters
poolpointer to pool that will be initialized
elementSizetotal size of a single element, in bytes.
+ Here is the caller graph for this function:

◆ vlAsyncPoolNew()

vl_async_pool * vlAsyncPoolNew ( vl_uint16_t elementSize)

Allocates and initializes a new async pool.

The specified pool must later be deleted via vlAsyncPoolDelete.

See also
vlAsyncPoolDelete
Parameters
elementSize
Returns
pointer to newly allocated async pool.
+ Here is the call graph for this function:

◆ vlAsyncPoolReset()

void vlAsyncPoolReset ( vl_async_pool * pool)

Resets the specified async pool, returning it to its state when it was first initialized.

This frees all allocated blocks of nodes up to the first.

Warning
This will invalidate all elements taken prior to this call. Manual synchronization is highly recommended.
Parameters
poolpointer to the async pool to reset
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlAsyncPoolReturn()

void vlAsyncPoolReturn ( vl_async_pool * pool,
void * element )

Returns an element to the specified async pool.

Parameters
poolpointer to async pool
elementpointer to returned element
Complexity of O(1) constant.
+ Here is the caller graph for this function:

◆ vlAsyncPoolTake()

void * vlAsyncPoolTake ( vl_async_pool * pool)

Takes an element from the specified async pool.

Parameters
poolpointer to async pool
Complexity of O(1) constant.
Returns
pointer to taken element
+ Here is the caller graph for this function:

Variable Documentation

◆ VL_ASYNC_POOL_BLOCK_ALIGNMENT

const vl_ularge_t VL_ASYNC_POOL_BLOCK_ALIGNMENT = 32

Byte-level alignment of individual vlAsyncPool memory blocks.

◆ VL_ASYNC_POOL_NODE_ALIGNMENT

const vl_ularge_t VL_ASYNC_POOL_NODE_ALIGNMENT = 16

Byte-level alignment of individual vlAsyncPool element nodes.