Loading...
Searching...
No Matches
osmium::thread::Queue< T > Class Template Reference

`#include <queue.hpp>`

## Public Member Functions

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

## Private Attributes

const std::size_t | m_max_size
const std::string | m_name
| Name of this queue (for debugging only).
std::mutex | m_mutex
std::queue< T > | m_queue
std::condition_variable | m_data_available
| Used to signal consumers when data is available in the queue.
std::condition_variable | m_space_available
| Used to signal producers when queue is not full.
std::atomic< bool > | m_in_use {true}

## Detailed Description

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

A thread-safe queue.

## Constructor & Destructor Documentation

## Queue() [1/3]

template<typename T>

osmium::thread::Queue< T >::Queue | ( | std::size_t | max_size = 0,
|  | 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.)

## Queue() [2/3]

template<typename T>

osmium::thread::Queue< T >::Queue | ( | const Queue< T > & |  | ) |

delete

## Queue() [3/3]

template<typename T>

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

delete

## ~Queue()

template<typename T>

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

default

## Member Function Documentation

## empty()

template<typename T>

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

inline

## in_use()

template<typename T>

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

inline noexcept

## operator=() [1/2]

template<typename T>

Queue & osmium::thread::Queue< T >::operator= | ( | const Queue< T > & |  | ) |

delete

## operator=() [2/2]

template<typename T>

Queue & osmium::thread::Queue< T >::operator= | ( | Queue< T > && |  | ) |

delete

## push()

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.

## shutdown()

template<typename T>

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

inline

## size()

template<typename T>

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

inline

## try_pop()

template<typename T>

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

inline

## wait_and_pop()

template<typename T>

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

inline

## Member Data Documentation

## m_data_available

template<typename T>

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

private

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

## m_in_use

template<typename T>

std::atomic<bool> osmium::thread::Queue< T >::m_in_use {true}

private

## m_max_size

template<typename T>

const std::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.

## m_mutex

template<typename T>

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

mutable private

## m_name

template<typename T>

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

private

Name of this queue (for debugging only).

## m_queue

template<typename T>

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

private

## m_space_available

template<typename T>

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

private

Used to signal producers when queue is not full.

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

- include/osmium/thread/queue.hpp