Hedgehog  0.0.0
A library to generate hybrid pipeline workflow systems
hh::behavior::Pool< ManagedData > Class Template Reference

Pool that is used by the memory manager. More...

#include "pool.h"

Inheritance diagram for hh::behavior::Pool< ManagedData >:
Inheritance graph
Collaboration diagram for hh::behavior::Pool< ManagedData >:
Collaboration graph

Public Member Functions

 Pool (size_t const &capacity)
 Pool constructor defining capacity. More...
 
std::deque< std::shared_ptr< ManagedData > > const & queue () const
 Queue container accessor. More...
 
std::deque< std::shared_ptr< ManagedData > >::iterator begin ()
 Begin iterator accessor for the queue's container. More...
 
std::deque< std::shared_ptr< ManagedData > >::iterator end ()
 End iterator accessor for the queue's container. More...
 
size_t size ()
 Queue size accessor. More...
 
bool empty ()
 Emptiness queue accessor. More...
 
size_t capacity () const
 Capacity accessor. More...
 
void push_back (std::shared_ptr< ManagedData > const &data)
 Push back data into the pool. More...
 
std::shared_ptr< ManagedData > pop_front ()
 Return and pop the fist element from the queue, it the queue is empty wait for an element to come back. More...
 

Private Attributes

size_t capacity_ = 1
 Pool capacity, maximum size.
 
std::deque< std::shared_ptr< ManagedData > > queue_ = {}
 Container used to store pool's data.
 
std::mutex mutex_ = {}
 Pool mutex to protect pool access.
 
std::unique_ptr< std::condition_variable > conditionVariable_ = std::make_unique<std::condition_variable>()
 Condition variable to wait on data for empty queue.
 

Detailed Description

template<class ManagedData>
class hh::behavior::Pool< ManagedData >

Pool that is used by the memory manager.

Template Parameters
ManagedDataType stored in the pool

Definition at line 36 of file pool.h.

Constructor & Destructor Documentation

◆ Pool()

template<class ManagedData>
hh::behavior::Pool< ManagedData >::Pool ( size_t const &  capacity)
inlineexplicit

Pool constructor defining capacity.

If the capacity given is 0, it set to 1

Parameters
capacityPool capacity

Definition at line 49 of file pool.h.

Member Function Documentation

◆ begin()

template<class ManagedData>
std::deque<std::shared_ptr<ManagedData> >::iterator hh::behavior::Pool< ManagedData >::begin ( )
inline

Begin iterator accessor for the queue's container.

Attention
Not protected with mutex
Returns
Begin iterator for the queue's container

Definition at line 62 of file pool.h.

◆ capacity()

template<class ManagedData>
size_t hh::behavior::Pool< ManagedData >::capacity ( ) const
inline

Capacity accessor.

Attention
Not protected with mutex
Returns
Queue accessor

Definition at line 85 of file pool.h.

Here is the caller graph for this function:

◆ empty()

template<class ManagedData>
bool hh::behavior::Pool< ManagedData >::empty ( )
inline

Emptiness queue accessor.

Attention
Not protected with mutex
Returns
True if queue empty, else False

Definition at line 80 of file pool.h.

◆ end()

template<class ManagedData>
std::deque<std::shared_ptr<ManagedData> >::iterator hh::behavior::Pool< ManagedData >::end ( )
inline

End iterator accessor for the queue's container.

Attention
Not protected with mutex
Returns
End iterator for the queue's container

Definition at line 67 of file pool.h.

◆ pop_front()

template<class ManagedData>
std::shared_ptr<ManagedData> hh::behavior::Pool< ManagedData >::pop_front ( )
inline

Return and pop the fist element from the queue, it the queue is empty wait for an element to come back.

Returns
The queue front element

Definition at line 106 of file pool.h.

◆ push_back()

template<class ManagedData>
void hh::behavior::Pool< ManagedData >::push_back ( std::shared_ptr< ManagedData > const &  data)
inline

Push back data into the pool.

Exceptions
std::runtime_errorQueue overflow, too much push_back
Parameters
dataData to push back

Definition at line 90 of file pool.h.

◆ queue()

template<class ManagedData>
std::deque<std::shared_ptr<ManagedData> > const& hh::behavior::Pool< ManagedData >::queue ( ) const
inline

Queue container accessor.

Attention
Not protected with mutex
Returns
Queue container

Definition at line 57 of file pool.h.

◆ size()

template<class ManagedData>
size_t hh::behavior::Pool< ManagedData >::size ( )
inline

Queue size accessor.

Attention
Protected with mutex
Returns
Queue size

Definition at line 72 of file pool.h.


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