COROIO: NNet::TArenaAllocator< T, PoolSize > Class Template Reference
COROIO
 
Loading...
Searching...
No Matches
NNet::TArenaAllocator< T, PoolSize > Class Template Reference

Arena allocator to preallocate memory for IOCP events. More...

#include <iocp.hpp>

Public Member Functions

T * allocate ()
 
void deallocate (T *obj)
 
int count () const
 

Detailed Description

template<typename T, size_t PoolSize = 1024>
class NNet::TArenaAllocator< T, PoolSize >

Arena allocator to preallocate memory for IOCP events.

This class implements an arena allocator that preallocates memory in blocks (of size PoolSize) to avoid individual heap allocations for each IOCP event structure. This is necessary for efficiency when working with the IOCP API, which may require frequent allocation and deallocation of event objects.

Template Parameters
TThe type of object to allocate (e.g. IOCP event structure).
PoolSizeThe number of objects in each preallocated pool (default is 1024).
// Example usage:
TArenaAllocator<TIO> allocator;
TIO* ioEvent = allocator.allocate();
// use ioEvent...
allocator.deallocate(ioEvent);

The documentation for this class was generated from the following file: