Main Page | Class List | File List | Class Members

Rha::BoundedQueue< T, C > Class Template Reference

Implementation of bounded queue. More...

#include <BoundedQueue.hpp>

List of all members.

Public Types

typedef BoundedQueue< T, C > OfType
typedef T Task
typedef C Container

Public Member Functions

 BoundedQueue ()
 Constructs BoundedQueue with default configurator.

 BoundedQueue (const OfType &queue)
 Constructs BoundedQueue using configuration from passed BoundedQueue object.

 BoundedQueue (const Configurator &config)
 Constructs BoundedQueue using supplied configuration object.

 ~BoundedQueue ()
 Destructs instance of BoundedQueue object.

void setUp ()
 Initializes queuing environemnt.

bool empty () const
 Returns true if queue does not have any tasks.

bool full () const
 Returns true if queue has reached upper bound.

void flush ()
 Clears the queue.

Task & front ()
 Returns reference to the front task in the queue which must be non-empty.

const Task & front () const
void push (const Task &val)
 Pushes a task onto the queue for pickup by Executor.

void pop ()
 Removes a front task from the queue.


Detailed Description

template<class T, class C = std::deque<T>>
class Rha::BoundedQueue< T, C >

Implementation of bounded queue.

Use BoundedQueue class to create objects that will serve as bounded task queues. Scheduler uses an instance of a queue object to buffer arriving tasks. BoundedQueue has a property called upper bound which restricts the maximum number of tasks that can be queued. If upper bound limit is reached and a new task is scheduled, QueueOverflowError exception is thrown. To prevent this, Scheduler calls full() method of a queue before putting new tasks. BoundedQueue can be combined with other types of queues to achieve desired functionality. For example, one can combine BoundedQueue with SortedQueue; the resulting queue will be a priority, bounded queue.


Constructor & Destructor Documentation

template<class T, class C>
Rha::BoundedQueue< T, C >::BoundedQueue const OfType queue  ) 
 

Constructs BoundedQueue using configuration from passed BoundedQueue object.

Parameters:
queue instance of BoundedQueue object from which configuration will be read to initialize this.

template<class T, class C>
Rha::BoundedQueue< T, C >::BoundedQueue const Configurator config  ) 
 

Constructs BoundedQueue using supplied configuration object.

Parameters:
config instance of Configurator object from which configuration will be read to initialize this.

template<class T, class C>
Rha::BoundedQueue< T, C >::~BoundedQueue  ) 
 

Destructs instance of BoundedQueue object.

Attention:
Declared as non-virtual.


Member Function Documentation

template<class T, class C>
bool Rha::BoundedQueue< T, C >::empty  )  const [inline]
 

Returns true if queue does not have any tasks.

Otherwise returns false.

Exceptions:
doesn't throw

template<class T, class C>
void Rha::BoundedQueue< T, C >::flush  )  [inline]
 

Clears the queue.

Exceptions:
doesn't throw

template<class T, class C>
Rha::BoundedQueue< T, C >::Task & Rha::BoundedQueue< T, C >::front  )  [inline]
 

Returns reference to the front task in the queue which must be non-empty.

Exceptions:
doesn't throw

template<class T, class C>
bool Rha::BoundedQueue< T, C >::full  )  const [inline]
 

Returns true if queue has reached upper bound.

Otherwise returns false.

Exceptions:
doesn't throw

template<class T, class C>
void Rha::BoundedQueue< T, C >::pop  )  [inline]
 

Removes a front task from the queue.

Exceptions:
doesn't throw

template<class T, class C>
void Rha::BoundedQueue< T, C >::push const Task &  val  )  [inline]
 

Pushes a task onto the queue for pickup by Executor.

Exceptions:
QueueOverflowError if upper bound is reached.

template<class T, class C>
void Rha::BoundedQueue< T, C >::setUp  )  [inline]
 

Initializes queuing environemnt.

Called just before Scheduler begins queing tasks.


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