Veritable Lasagna
An Allocator & Data Structure Library for C.
Loading...
Searching...
No Matches
vl_async_pool.h
Go to the documentation of this file.
1
14#ifndef VL_ASYNC_POOL_H
15#define VL_ASYNC_POOL_H
16
17#include "vl_atomic.h"
18#include "vl_atomic_ptr.h"
19#include "vl_memory.h"
20
87typedef struct vl_async_pool
88{
89 vl_atomic_ptr freeStack;
90 vl_atomic_uint32_t freeLength;
92 vl_atomic_ptr primaryBlock;
93 vl_atomic_bool_t allocatingFlag;
94 vl_atomic_uint16_t totalBlocks;
96 vl_uint16_t elementSize;
97 vl_uint16_t elementAlign;
98 vl_uint16_t nodeSize;
99} vl_async_pool;
100
104typedef struct
105{
106 vl_uintptr_t next;
107} vl_async_pool_header;
108
132VL_API void vlAsyncPoolInitAligned(vl_async_pool* pool, vl_uint16_t elementSize, vl_uint16_t elementAlign);
133
143static inline void vlAsyncPoolInit(vl_async_pool* pool, vl_uint16_t elementSize)
144{
146}
147
159VL_API void vlAsyncPoolFree(vl_async_pool* pool);
160
173VL_API vl_async_pool* vlAsyncPoolNewAligned(vl_uint16_t elementSize, vl_uint16_t elementAlign);
174
184static inline vl_async_pool* vlAsyncPoolNew(vl_uint16_t elementSize)
185{
187}
188
201VL_API void vlAsyncPoolDelete(vl_async_pool* pool);
202
214VL_API void vlAsyncPoolReset(vl_async_pool* pool);
215
227VL_API void vlAsyncPoolClear(vl_async_pool* pool);
228
247VL_API void* vlAsyncPoolTake(vl_async_pool* pool);
248
256VL_API void vlAsyncPoolReturn(vl_async_pool* pool, void* element);
257
258#endif // VL_ASYNC_POOL_H
VL_API void vlAsyncPoolFree(vl_async_pool *pool)
Frees the specified async pool, and all associated memory.
Definition vl_async_pool.c:88
VL_API void vlAsyncPoolInitAligned(vl_async_pool *pool, vl_uint16_t elementSize, vl_uint16_t elementAlign)
Initializes the specified async pool, with the specified alignment.
Definition vl_async_pool.c:72
VL_API void vlAsyncPoolDelete(vl_async_pool *pool)
Deinitializes and deletes the specified async pool, and all associated memory.
Definition vl_async_pool.c:108
VL_API vl_async_pool * vlAsyncPoolNewAligned(vl_uint16_t elementSize, vl_uint16_t elementAlign)
Allocates and initializes a new async pool, and specified alignment.
Definition vl_async_pool.c:101
VL_API void vlAsyncPoolReturn(vl_async_pool *pool, void *element)
Returns an element to the specified async pool.
Definition vl_async_pool.c:199
VL_API void * vlAsyncPoolTake(vl_async_pool *pool)
Takes an element from the specified async pool.
Definition vl_async_pool.c:158
VL_API void vlAsyncPoolReset(vl_async_pool *pool)
Resets the specified async pool, returning it to its state when it was first initialized.
Definition vl_async_pool.c:114
VL_API void vlAsyncPoolClear(vl_async_pool *pool)
Resets the state of all blocks and the pool, retaining memory but invalidating taken elements.
Definition vl_async_pool.c:139
VL_ATOMIC vl_tagged_ptr vl_atomic_ptr
Atomic variant of vl_tagged_ptr.
Definition vl_atomic_ptr.h:60
#define VL_DEFAULT_MEMORY_ALIGN
Default memory alignment. Defaults to maximum system word size.
Definition vl_memory.h:60
VL_UPTR_T vl_uintptr_t
Unsigned integer type suitable for expressing memory addresses.
Definition vl_numtypes.h:163