yat  0.18pre
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
theplu::yat::utility::Queue< T > Class Template Reference

Multi-thread safe queue. More...

#include <yat/utility/Queue.h>

Inheritance diagram for theplu::yat::utility::Queue< T >:
theplu::yat::utility::detail::BasicQueue< Queue< T >, T, std::deque< T > >

Public Types

typedef std::deque< T >::value_type value_type
 Type of object stored.
 
typedef std::deque< T >::size_type size_type
 

Public Member Functions

 Queue (void)
 Create a Queue with no elements.
 
 Queue (const Queue &other)
 Copy constructor.
 
Queueoperator= (const Queue &lhs)
 assignment operator
 
void clear (void)
 clear queue More...
 
bool empty (void) const
 
void pop (T &value)
 access next element in queue More...
 
void push (const T &t)
 insert an element into container
 
void push (T &&t)
 insert an element into container More...
 
size_type size (void) const
 
bool try_pop (T &value)
 

Protected Member Functions

void assign (const BasicQueue &other)
 

Protected Attributes

std::deque< T > q_
 data
 

Friends

class detail::BasicQueue< Queue< T >, T, std::deque< T > >
 

Detailed Description

template<typename T>
class theplu::yat::utility::Queue< T >

Multi-thread safe queue.

This class provides a multi-thread safe queue. The Queue is typically shared by multiple threads such that some threads push elements and some pop elements. The Queue is a "first in first out" container and holds the same functionality as the similar std::queue. The difference is that Queue is multi-thread safe, in other words, when one thread access the Queue, other threads are locked out from access so that only one thread touches the Queue at a time and its behaviour is well defined. In a single-thread application there is no point in using the class as std::queue should be prefereble.

Note
Copy constructor and assignment are available but they are not thread safe in the current implementation.
Since
New in yat 0.11
See also
Boost Library provides a lock-free queue

Member Typedef Documentation

typedef std::deque< T > ::size_type theplu::yat::utility::detail::BasicQueue< Queue< T > , T, std::deque< T > >::size_type
inherited

An unsigned integral type.

See also
size(void)

Member Function Documentation

void theplu::yat::utility::detail::BasicQueue< Queue< T > , T, std::deque< T > >::assign ( const BasicQueue< Queue< T >, T, std::deque< T > > &  other)
inlineprotectedinherited

assign other to this

void theplu::yat::utility::detail::BasicQueue< Queue< T > , T, std::deque< T > >::clear ( void  )
inlineinherited

clear queue

Since
new in yat 0.15
bool theplu::yat::utility::detail::BasicQueue< Queue< T > , T, std::deque< T > >::empty ( void  ) const
inlineinherited
Returns
true if container's size is zero
void theplu::yat::utility::detail::BasicQueue< Queue< T > , T, std::deque< T > >::pop ( T &  value)
inlineinherited

access next element in queue

Access the next element is queue. If container is empty, process is waiting until other process is inserting element into container.

void theplu::yat::utility::detail::BasicQueue< Queue< T > , T, std::deque< T > >::push ( T &&  t)
inlineinherited

insert an element into container

Note
only available if configured and built with cxx11 support
Since
New in yat 0.15
size_type theplu::yat::utility::detail::BasicQueue< Queue< T > , T, std::deque< T > >::size ( void  ) const
inlineinherited
Returns
Number of elements stored in container
bool theplu::yat::utility::detail::BasicQueue< Queue< T > , T, std::deque< T > >::try_pop ( T &  value)
inlineinherited

If Queue is empty() do nothing and return false, else pop the element into value and return true


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

Generated on Sun Sep 27 2020 02:26:14 for yat by  doxygen 1.8.11