OnixS C++ FIX Engine  4.2.0
API Documentation
ThreadSafePool Class Reference

#include <OnixS/FIXEngine/Threading/ThreadSafePool.h>

Public Member Functions

 ThreadSafePool (size_t preferredSize, PoolAllocatorBase &allocator)
 ~ThreadSafePool ()
void get (ItemBaseUniquePtr &poolItem)
void put (ItemBaseUniquePtr &poolItem)
size_t preferredSize ()

Detailed Description

The pool is safe for many writers and one reader. The common scenario : a producer of data creates the objects using the pool and sends them to a consumer threads to process, then these threads returns objects back to producer's pool and so on.

Definition at line 33 of file ThreadSafePool.h.

Constructor & Destructor Documentation

ThreadSafePool ( size_t  preferredSize,
PoolAllocatorBase allocator 

Initializes the instance.

preferredSizeThe preferred size of the pool.
allocatorThe allocator to provide a strategy to create/destroy pool items.

Removes pooled elements and cleans up internal resources.

Member Function Documentation

void get ( ItemBaseUniquePtr poolItem)

Gets an item from the pool.

Gives the ownership of the item to the smart pointer. If the pool is empty then creates an item by the allocator strategy. If the number of allocated elements becomes greater than the preferred pool size, after a high load, then destroys a one element, when possible, by the allocator strategy.

poolItemThe smart pointer to store the pool item.
size_t preferredSize ( )

Returns the preferred size of the pool.

void put ( ItemBaseUniquePtr poolItem)

Returns an item to the pool.

Takes the ownership of the item from the smart pointer.

DomainExceptionif the smart pointer is null.
poolItemThe smart pointer to the pool item for returning to the pool.

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