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

#include <circular_q.h>

Public Types

using item_type = T
 

Public Member Functions

 circular_q (size_t max_items)
 
void push_back (T &&item)
 
void pop_front (T &popped_item)
 
bool empty ()
 
bool full ()
 
size_t overrun_counter () const
 

Private Attributes

size_t max_items_
 
std::vector< T >::size_type head_ = 0
 
std::vector< T >::size_type tail_ = 0
 
std::vector< T > v_
 
size_t overrun_counter_ = 0
 

Detailed Description

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

Definition at line 14 of file circular_q.h.

Member Typedef Documentation

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

Definition at line 17 of file circular_q.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file circular_q.h.

20  : max_items_(max_items + 1) // one item is reserved as marker for full q
21  , v_(max_items_)
22  {
23  }
std::vector< T > v_
Definition: circular_q.h:67

Member Function Documentation

template<typename T>
bool spdlog::details::circular_q< T >::empty ( void  )
inline

Definition at line 46 of file circular_q.h.

47  {
48  return tail_ == head_;
49  }
std::vector< T >::size_type tail_
Definition: circular_q.h:65
std::vector< T >::size_type head_
Definition: circular_q.h:64
template<typename T>
bool spdlog::details::circular_q< T >::full ( )
inline

Definition at line 51 of file circular_q.h.

52  {
53  // head is ahead of the tail by 1
54  return ((tail_ + 1) % max_items_) == head_;
55  }
std::vector< T >::size_type tail_
Definition: circular_q.h:65
std::vector< T >::size_type head_
Definition: circular_q.h:64
template<typename T>
size_t spdlog::details::circular_q< T >::overrun_counter ( ) const
inline

Definition at line 57 of file circular_q.h.

58  {
59  return overrun_counter_;
60  }
template<typename T>
void spdlog::details::circular_q< T >::pop_front ( T &  popped_item)
inline

Definition at line 40 of file circular_q.h.

41  {
42  popped_item = std::move(v_[head_]);
43  head_ = (head_ + 1) % max_items_;
44  }
std::vector< T > v_
Definition: circular_q.h:67
def move(depos, offset)
Definition: depos.py:107
std::vector< T >::size_type head_
Definition: circular_q.h:64
template<typename T>
void spdlog::details::circular_q< T >::push_back ( T &&  item)
inline

Definition at line 26 of file circular_q.h.

27  {
28  v_[tail_] = std::move(item);
29  tail_ = (tail_ + 1) % max_items_;
30 
31  if (tail_ == head_) // overrun last item if full
32  {
33  head_ = (head_ + 1) % max_items_;
35  }
36  }
std::vector< T > v_
Definition: circular_q.h:67
std::vector< T >::size_type tail_
Definition: circular_q.h:65
def move(depos, offset)
Definition: depos.py:107
std::vector< T >::size_type head_
Definition: circular_q.h:64

Member Data Documentation

template<typename T>
std::vector<T>::size_type spdlog::details::circular_q< T >::head_ = 0
private

Definition at line 64 of file circular_q.h.

template<typename T>
size_t spdlog::details::circular_q< T >::max_items_
private

Definition at line 63 of file circular_q.h.

template<typename T>
size_t spdlog::details::circular_q< T >::overrun_counter_ = 0
private

Definition at line 69 of file circular_q.h.

template<typename T>
std::vector<T>::size_type spdlog::details::circular_q< T >::tail_ = 0
private

Definition at line 65 of file circular_q.h.

template<typename T>
std::vector<T> spdlog::details::circular_q< T >::v_
private

Definition at line 67 of file circular_q.h.


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