Queue< T > Class Template Reference

#include <Pt/System/Queue.h>

This class implements a thread safe queue. More...

Public Member Functions

 Queue ()
 Default Constructor.
 
bool empty () const
 Returns true, if the queue is empty.
 
value_type get ()
 Returns the next element. More...
 
void maxSize (size_type m)
 sets the maximum size of the queue. More...
 
size_type maxSize () const
 returns the maximum size of the queue.
 
size_type numWaiting () const
 returns the number of threads blocked in the get method.
 
void put (const_reference element)
 Adds a element to the queue. More...
 
size_type size () const
 Returns the number of elements currently in queue.
 

Detailed Description

template<typename T>
class Pt::System::Queue< T >

A queue is a container where the elements put into the queue are fetched in the same order (first-in-first-out, fifo). The class has a optional maximum size. If the size is set to 0 the queue has no limit. Otherwise putting a element to the queue may block until another thread fetches a element or icreases the limit.

Member Function Documentation

Queue< T >::value_type get ( )

This method returns the next element. If the queue is empty, the thread will be locked until a element is available.

void put ( const_reference  element)

This method adds a element to the queue. If the queue has reached his maximum size, the method blocks until there is space available.

void maxSize ( size_type  m)

Setting the maximum size of the queue may wake up another thread, if it is waiting for space to get available and the limit is increased.