OpenStudio:utilities
 AllClasses Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages

#include "Queue.hpp"

Public Member Functions

void add (const T &item)
void cancel_get ()
bool canceled ()
get_next ()
get_next_non_blocking ()
bool has_next ()
 Queue ()
void reset ()
 ~Queue ()

Detailed Description

template<typename T>
class openstudio::Queue< T >

Thread safe Queue for message processing.

Queue allows the user to push messages in a thread-safe non-blocking way and read queue messages in either blocking or non-blocking methods. The blocking methods allow a thread to wait on new messages without being in a busy loop and be notified when the new message is received.

Constructor & Destructor Documentation

template<typename T >
openstudio::Queue< T >::Queue ( )
inline
template<typename T >
openstudio::Queue< T >::~Queue ( )
inline

Member Function Documentation

template<typename T >
void openstudio::Queue< T >::add ( const T &  item)
inline

Add an item to the Queue for processing.

Parameters
[in]itemitem to add
template<typename T >
void openstudio::Queue< T >::cancel_get ( )
inline

Cancel the current read operation.

Pending readers will be woken and with throw an exception.

template<typename T >
bool openstudio::Queue< T >::canceled ( )
inline

Returns if in canceled state.

Returns
true if Queue had been canceled and not reset
template<typename T >
T openstudio::Queue< T >::get_next ( )
inline

get the next available item in the message Queue.

Method blocks until a new item is available

Returns
true if item is populated false if not, if the read was canceled before an item was made available.
template<typename T >
T openstudio::Queue< T >::get_next_non_blocking ( )
inline

get the next available item, but do not block if there are none available instead throw()

template<typename T >
bool openstudio::Queue< T >::has_next ( )
inline

Return true if there is currently data available.

template<typename T >
void openstudio::Queue< T >::reset ( )
inline

Reset canceled state to false.