Thread-safe queue.
More...
#include <safe_queue.h>
|
bool | Push (const T &e) |
| Push an element into the queue. More...
|
|
void | Pop (T &e) |
| Pop an element from the queue. More...
|
|
bool | Pop (T &item, std::uint64_t timeout) |
| Pop an item from the queue until one element is poped or timout. More...
|
|
bool | TryPop (T &e) |
| Try to pop an element from the queue. More...
|
|
unsigned int | Size () const |
|
template<typename T, class Container = std::queue<T>>
class SafeQueue< T, Container >
Thread-safe queue.
◆ Pop() [1/2]
template<typename T, class Container = std::queue<T>>
Pop an element from the queue.
It will be blocked until one element is poped.
◆ Pop() [2/2]
template<typename T, class Container = std::queue<T>>
bool SafeQueue< T, Container >::Pop |
( |
T & |
item, |
|
|
std::uint64_t |
timeout |
|
) |
| |
|
inline |
Pop an item from the queue until one element is poped or timout.
- Parameters
-
[in] | timeout,return | false after waiting this number of microseconds |
◆ Push()
template<typename T, class Container = std::queue<T>>
bool SafeQueue< T, Container >::Push |
( |
const T & |
e | ) |
|
|
inline |
Push an element into the queue.
Blocking operation.
- Returns
- true if success;
◆ Size()
template<typename T, class Container = std::queue<T>>
unsigned int SafeQueue< T, Container >::Size |
( |
| ) |
const |
|
inline |
- Returns
- Number of elements in the queue.
◆ TryPop()
template<typename T, class Container = std::queue<T>>
bool SafeQueue< T, Container >::TryPop |
( |
T & |
e | ) |
|
|
inline |
Try to pop an element from the queue.
- Returns
- false the queue is empty now.
The documentation for this class was generated from the following file: