Apache Singa
A General Distributed Deep Learning Library
Classes | Public Member Functions | List of all members
PriorityQueue< T > Class Template Reference

Thread safe priority queue. More...

#include <safe_queue.h>

Public Member Functions

bool Push (const T &e, int priority)
 Push an element into the queue with a given priority. More...
 
void Pop (T &e)
 Pop an element from the queue with the highest priority. More...
 
bool Pop (T &e, std::uint64_t timeout)
 Pop the item with the highest priority from the queue until one element is poped or timeout. More...
 
bool TryPop (T &e)
 Try to pop an element from the queue. More...
 
unsigned int Size () const
 

Detailed Description

template<typename T>
class PriorityQueue< T >

Thread safe priority queue.

Member Function Documentation

◆ Pop() [1/2]

template<typename T >
void PriorityQueue< T >::Pop ( T &  e)
inline

Pop an element from the queue with the highest priority.

It blocks until one element is poped.

◆ Pop() [2/2]

template<typename T >
bool PriorityQueue< T >::Pop ( T &  e,
std::uint64_t  timeout 
)
inline

Pop the item with the highest priority from the queue until one element is poped or timeout.

Parameters
[in]timeout,returnfalse if no element is poped after this number of microseconds.

◆ Push()

template<typename T >
bool PriorityQueue< T >::Push ( const T &  e,
int  priority 
)
inline

Push an element into the queue with a given priority.

The queue should not be a priority queue.

Returns
true if success; otherwise false, e.g., due to capacity constraint.

◆ Size()

template<typename T >
unsigned int PriorityQueue< T >::Size ( ) const
inline
Returns
Number of elements in the queue.

◆ TryPop()

template<typename T >
bool PriorityQueue< T >::TryPop ( T &  e)
inline

Try to pop an element from the queue.

Returns
false if the queue is empty now.

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