yat  0.13.2pre
Public Types | Public Member Functions | List of all members
theplu::yat::utility::PriorityQueue< T, Compare > Class Template Reference

Multi-thread safe priority queue. More...

#include <yat/utility/PriorityQueue.h>

Public Types

typedef T value_type
 Type of object stored in Queue.
 
typedef std::set< T, Compare >
::size_type 
size_type
 

Public Member Functions

 PriorityQueue (void)
 Create a PriorityQueue with no elements.
 
 PriorityQueue (const Compare &comp)
 Create a PriorityQueue with comp as Compare functor.
 
 PriorityQueue (const PriorityQueue &other)
 Copy constructor. More...
 
bool empty (void) const
 
void pop (T &value)
 access next element is queue More...
 
void push (const T &t)
 insert an element into container
 
size_type size (void) const
 
bool try_pop (T &value)
 
PriorityQueueoperator= (const PriorityQueue &lhs)
 assignment operator More...
 

Detailed Description

template<typename T, class Compare = std::less<T>>
class theplu::yat::utility::PriorityQueue< T, Compare >

Multi-thread safe priority queue.

This class provides a multi-thread safe priority_queue. The PriorityQueue is typically shared by multiple threads such that some threads push elements and some pop elements. The PriorityQueue is a specifically designed so you can only access the greatest element similar tostd::priority_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.13

Member Typedef Documentation

template<typename T, class Compare = std::less<T>>
typedef std::set<T, Compare>::size_type theplu::yat::utility::PriorityQueue< T, Compare >::size_type

An unsigned integral type.

See Also
size(void)

Constructor & Destructor Documentation

template<typename T, class Compare = std::less<T>>
theplu::yat::utility::PriorityQueue< T, Compare >::PriorityQueue ( const PriorityQueue< T, Compare > &  other)
inline

Copy constructor.

Note
is not thread safe

Member Function Documentation

template<typename T, class Compare = std::less<T>>
bool theplu::yat::utility::PriorityQueue< T, Compare >::empty ( void  ) const
inline
Returns
true if size is zero
template<typename T, class Compare = std::less<T>>
PriorityQueue& theplu::yat::utility::PriorityQueue< T, Compare >::operator= ( const PriorityQueue< T, Compare > &  lhs)
inline

assignment operator

Note
is not thread safe
template<typename T, class Compare = std::less<T>>
void theplu::yat::utility::PriorityQueue< T, Compare >::pop ( T &  value)
inline

access next element is queue

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

template<typename T, class Compare = std::less<T>>
size_type theplu::yat::utility::PriorityQueue< T, Compare >::size ( void  ) const
inline
Returns
Number of elements stored in container
template<typename T, class Compare = std::less<T>>
bool theplu::yat::utility::PriorityQueue< T, Compare >::try_pop ( T &  value)
inline

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 Wed Jan 4 2017 02:23:08 for yat by  doxygen 1.8.5