osmium::thread::Queue< T > Class Template Reference

`#include <queue.hpp>`

## Public Member Functions

| Queue (size_t max_size=0, const std::string &name="")
| ~Queue ()
void | push (T value)
void | shutdown ()
void | wait_and_pop (T &value)
void | wait_and_pop_with_timeout (T &value)
bool | try_pop (T &value)
bool | empty () const
size_t | size () const

## Private Attributes

const size_t | m_max_size
const std::string | m_name
| Name of this queue (for debugging only). More...
std::mutex | m_mutex
std::queue< T > | m_queue
std::condition_variable | m_data_available
| Used to signal readers when data is available in the queue. More...
std::atomic< bool > | m_done

## Detailed Description

### template<typename T>
class osmium::thread::Queue< T >

A thread-safe queue.

## Constructor & Destructor Documentation

template<typename T>

osmium::thread::Queue< T >::Queue | ( | size_t | max_size = `0`,
|  | const std::string & | name = `""`
| ) |  |

inline explicit

Construct a multithreaded queue.

Parameters

  max_size | Maximum number of elements in the queue. Set to 0 for an unlimited size.
  name | Optional name for this queue. (Used for debugging.)

template<typename T>

osmium::thread::Queue< T >::~Queue | ( |  | ) |

inline

## Member Function Documentation

template<typename T>

bool osmium::thread::Queue< T >::empty | ( |  | ) | const

inline

template<typename T>

void osmium::thread::Queue< T >::push | ( | T | value | ) |

inline

Push an element onto the queue. If the queue has a max size, this call will block if the queue is full.

template<typename T>

void osmium::thread::Queue< T >::shutdown | ( |  | ) |

inline

template<typename T>

size_t osmium::thread::Queue< T >::size | ( |  | ) | const

inline

template<typename T>

bool osmium::thread::Queue< T >::try_pop | ( | T & | value | ) |

inline

template<typename T>

void osmium::thread::Queue< T >::wait_and_pop | ( | T & | value | ) |

inline

template<typename T>

void osmium::thread::Queue< T >::wait_and_pop_with_timeout | ( | T & | value | ) |

inline

## Member Data Documentation

template<typename T>

std::condition_variable osmium::thread::Queue< T >::m_data_available

private

Used to signal readers when data is available in the queue.

template<typename T>

std::atomic<bool> osmium::thread::Queue< T >::m_done

private

template<typename T>

const size_t osmium::thread::Queue< T >::m_max_size

private

Maximum size of this queue. If the queue is full pushing to the queue will block.

template<typename T>

std::mutex osmium::thread::Queue< T >::m_mutex

mutable private

template<typename T>

const std::string osmium::thread::Queue< T >::m_name

private

Name of this queue (for debugging only).

template<typename T>

std::queue<T> osmium::thread::Queue< T >::m_queue

private

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

- osmium/thread/queue.hpp