Queue< T > Class Template Reference

#include <Pt/System/Queue.h>

Thread-safe FIFO queue. More...

Public Member Functions

 Queue ()
 Default Constructor.
value_type get ()
 Returns the next element.
void put (const_reference element)
 Adds a element to the queue.
bool empty () const
 Returns true, if the queue is empty.
size_type size () const
 Returns the number of elements currently in queue.
void maxSize (size_type m)
 sets the maximum size of the queue.
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.

Detailed Description

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

get() returns the next element and blocks while the queue is empty. put() appends an element and blocks when a maximum size is set and the queue is full. A maximum of zero means no limit. Raising the maximum may wake a thread blocked in put().

Member Function Documentation

◆ get()

template<typename T>
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.

◆ put()

template<typename T>
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.

◆ maxSize()

template<typename T>
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.