Public Types | Public Member Functions | Private Attributes | List of all members
spdlog::details::mpmc_blocking_queue< T > Class Template Reference

#include <mpmc_blocking_q.h>

Public Types

using item_type = T
 

Public Member Functions

 mpmc_blocking_queue (size_t max_items)
 
void enqueue (T &&item)
 
void enqueue_nowait (T &&item)
 
bool dequeue_for (T &popped_item, std::chrono::milliseconds wait_duration)
 
size_t overrun_counter ()
 

Private Attributes

std::mutex queue_mutex_
 
std::condition_variable push_cv_
 
std::condition_variable pop_cv_
 
spdlog::details::circular_q< T > q_
 

Detailed Description

template<typename T>
class spdlog::details::mpmc_blocking_queue< T >

Definition at line 24 of file mpmc_blocking_q.h.

Member Typedef Documentation

template<typename T>
using spdlog::details::mpmc_blocking_queue< T >::item_type = T

Definition at line 27 of file mpmc_blocking_q.h.

Constructor & Destructor Documentation

template<typename T>
spdlog::details::mpmc_blocking_queue< T >::mpmc_blocking_queue ( size_t  max_items)
inlineexplicit

Definition at line 28 of file mpmc_blocking_q.h.

29  : q_(max_items)
30  {
31  }
spdlog::details::circular_q< T > q_

Member Function Documentation

template<typename T>
bool spdlog::details::mpmc_blocking_queue< T >::dequeue_for ( T &  popped_item,
std::chrono::milliseconds  wait_duration 
)
inline

Definition at line 57 of file mpmc_blocking_q.h.

58  {
59  {
60  std::unique_lock<std::mutex> lock(queue_mutex_);
61  if (!push_cv_.wait_for(lock, wait_duration, [this] { return !this->q_.empty(); }))
62  {
63  return false;
64  }
65  q_.pop_front(popped_item);
66  }
67  pop_cv_.notify_one();
68  return true;
69  }
spdlog::details::circular_q< T > q_
template<typename T>
void spdlog::details::mpmc_blocking_queue< T >::enqueue ( T &&  item)
inline

Definition at line 35 of file mpmc_blocking_q.h.

36  {
37  {
38  std::unique_lock<std::mutex> lock(queue_mutex_);
39  pop_cv_.wait(lock, [this] { return !this->q_.full(); });
40  q_.push_back(std::move(item));
41  }
42  push_cv_.notify_one();
43  }
spdlog::details::circular_q< T > q_
def move(depos, offset)
Definition: depos.py:107
template<typename T>
void spdlog::details::mpmc_blocking_queue< T >::enqueue_nowait ( T &&  item)
inline

Definition at line 46 of file mpmc_blocking_q.h.

47  {
48  {
49  std::unique_lock<std::mutex> lock(queue_mutex_);
50  q_.push_back(std::move(item));
51  }
52  push_cv_.notify_one();
53  }
spdlog::details::circular_q< T > q_
def move(depos, offset)
Definition: depos.py:107
template<typename T>
size_t spdlog::details::mpmc_blocking_queue< T >::overrun_counter ( )
inline

Definition at line 108 of file mpmc_blocking_q.h.

109  {
110  std::unique_lock<std::mutex> lock(queue_mutex_);
111  return q_.overrun_counter();
112  }
spdlog::details::circular_q< T > q_

Member Data Documentation

template<typename T>
std::condition_variable spdlog::details::mpmc_blocking_queue< T >::pop_cv_
private

Definition at line 117 of file mpmc_blocking_q.h.

template<typename T>
std::condition_variable spdlog::details::mpmc_blocking_queue< T >::push_cv_
private

Definition at line 116 of file mpmc_blocking_q.h.

template<typename T>
spdlog::details::circular_q<T> spdlog::details::mpmc_blocking_queue< T >::q_
private

Definition at line 118 of file mpmc_blocking_q.h.

template<typename T>
std::mutex spdlog::details::mpmc_blocking_queue< T >::queue_mutex_
private

Definition at line 115 of file mpmc_blocking_q.h.


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