Bites
A small library of miscellaneous C++ codes.
 All Classes Namespaces Functions Friends Pages
Public Member Functions | List of all members
bites::ConcurrentQueue< Data > Class Template Reference

#include <ConcurrentQueue.hpp>

Public Member Functions

void push (Data const &data)
 
bool empty () const
 
bool try_pop (Data &popped_value)
 
void wait_and_pop (Data &popped_value)
 
std::queue< Data >::size_type size ()
 

Detailed Description

template<typename Data>
class bites::ConcurrentQueue< Data >

The ConcurrentQueue class is a thread-safe queue. Code is adapted from original posting by Anthony Williams at http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html

Member Function Documentation

template<typename Data >
void bites::ConcurrentQueue< Data >::push ( Data const &  data)
inline

Push data onto queue.

Parameters
datadata to be pushed.
template<typename Data >
bool bites::ConcurrentQueue< Data >::empty ( ) const
inline

Test whether the queue is empty.

Returns
whether the queue is empty (i.e. whether its size is zero.)
template<typename Data >
bool bites::ConcurrentQueue< Data >::try_pop ( Data &  popped_value)
inline
Parameters
popped_valuereference to popped value, if successful.
Returns
true if a value was popped, false otherwise (i.e. nothing in the queue.)
template<typename Data >
void bites::ConcurrentQueue< Data >::wait_and_pop ( Data &  popped_value)
inline

Pops value off the queue (waits until queue has value first.)

Parameters
popped_valuereference to popped value.
template<typename Data >
std::queue<Data>::size_type bites::ConcurrentQueue< Data >::size ( )
inline

Return size.

Returns
number of elements in the queue.

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