OnixS C++ CME MDP Premium Market Data Handler 5.11.1
Users' manual and API documentation
Loading...
Searching...
No Matches
MemoryPool Class Referenceabstract

#include <OnixS/CME/MDH/MemoryPool.h>

Public Member Functions

virtual void release () noexcept=0
virtual void * allocate (size_t size)=0
virtual void deallocate (void *block) noexcept=0

Protected Member Functions

 MemoryPool () noexcept=default
virtual ~MemoryPool () noexcept=default

Detailed Description

Pool instances created by makeMemoryPool() own their allocated storage and destroy themselves through release(). They are not deleted directly.

Note
The interface provides no synchronization. Callers must serialize concurrent access to the same pool.

Definition at line 51 of file MemoryPool.h.

Constructor & Destructor Documentation

◆ MemoryPool()

MemoryPool ( )
protecteddefaultnoexcept

Initializes the base of a concrete pool implementation.

◆ ~MemoryPool()

virtual ~MemoryPool ( )
protectedvirtualdefaultnoexcept

Finalizes the base of a concrete pool implementation.

Note
Pool users destroy instances through release().

Member Function Documentation

◆ allocate()

virtual void * allocate ( size_t size)
pure virtual

Obtains a raw memory block.

Parameters
sizeRequired capacity in bytes.
Returns
Pointer to the allocated storage.
Exceptions
std::length_errorIf the requested allocation or configured chunk is too large.
std::bad_allocIf storage cannot be allocated.

◆ deallocate()

virtual void deallocate ( void * block)
pure virtualnoexcept

Returns a previously allocated block to its owning pool.

Parameters
blockPointer returned by allocate(), or nullptr.
Note
Passing nullptr has no effect.

◆ release()

virtual void release ( )
pure virtualnoexcept

Destroys this pool and releases its storage.

Precondition
Every outstanding allocation has been returned with deallocate().
Note
The pool pointer and all storage obtained from it become invalid.