OpenStudioCore:utilities
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | List of all members
openstudio::Queue< T > Class Template Reference

#include <Queue.hpp>

Public Member Functions

void add (const T &item)
 Add an item to the Queue for processing. More...
 
void cancel_get ()
 Cancel the current read operation. More...
 
bool canceled ()
 Returns if in canceled state. More...
 
get_next ()
 get the next available item in the message Queue. More...
 
get_next_non_blocking ()
 get the next available item, but do not block if there are none available instead throw() More...
 
bool has_next ()
 Return true if there is currently data available. More...
 
 Queue ()
 
void reset ()
 Reset canceled state to false. More...
 
 ~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.