37#ifndef _UTILS_LIMITEDPOOL_HXX_
38#define _UTILS_LIMITEDPOOL_HXX_
57 unsigned entry_size,
unsigned entry_count,
Pool *
base_pool =
nullptr)
85 DIE(
"LimitedPool only supports async allocation.");
DynamicPool * mainBufferPool
main buffer pool instance
See OSMutexLock in os/OS.hxx.
Lightweight locking class for protecting small critical sections.
Abstract base class for all Buffers.
Pool * pool_
Reference to the pool from whence this buffer came.
An object that can be scheduled on an executor to run.
virtual void alloc_result(QMember *item)
Return the result of an alloc_async() from a memory Pool.
Implementation of a Pool interface that takes memory from mainBufferPool (configurable) but limits th...
Q waitingQueue_
Async allocators waiting for free buffers.
LimitedPool(unsigned entry_size, unsigned entry_count, Pool *base_pool=nullptr)
Pool * basePool_
Where to allocate memory from.
BufferBase * alloc_untyped(size_t size, Executable *flow) override
Internal helper funciton used by the Buffer implementation.
size_t free_items() override
Number of free items in the pool.
size_t free_items(size_t size) override
Number of free items in the pool for a given allocation size.
uint16_t itemSize_
How many bytes each entry should be.
void free(BufferBase *item) override
Function called when a buffer refcount reaches zero.
uint16_t freeCount_
How many entries can still be allocated.
Pool of previously allocated, but currently unused, items.
virtual void free(BufferBase *item)=0
Release an item back to the free pool.
virtual BufferBase * alloc_untyped(size_t size, Executable *flow)=0
Untyped buffer allocation method, used be descendants.
This class implements a linked list "queue" of buffers.
void insert(QMember *item, unsigned index=0)
Add an item to the back of the queue.
QMember * next(unsigned index)
Get an item from the front of the queue.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define DIE(MSG)
Unconditionally terminates the current process with a message.