KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SYNC_QUEUE< T > Class Template Reference

Synchronized, locking queue. More...

#include <sync_queue.h>

Public Member Functions

 SYNC_QUEUE ()
 
void push (T const &aValue)
 Push a value onto the queue.
 
void move_push (T &&aValue)
 Move a value onto the queue.
 
bool pop (T &aReceiver)
 Pop a value if the queue into the provided variable.
 
bool empty () const
 Return true if the queue is empty.
 
size_t size () const
 Return the size of the queue.
 
void clear ()
 Clear the queue.
 

Private Types

typedef std::lock_guard< std::mutex > GUARD
 

Private Attributes

std::queue< Tm_queue
 
std::mutex m_mutex
 

Detailed Description

template<typename T>
class SYNC_QUEUE< T >

Synchronized, locking queue.

Safe for multiple producer/multiple consumer environments with nontrivial data (though bear in mind data needs to be copied in and out).

Definition at line 31 of file sync_queue.h.

Member Typedef Documentation

◆ GUARD

template<typename T>
typedef std::lock_guard<std::mutex> SYNC_QUEUE< T >::GUARD
private

Definition at line 111 of file sync_queue.h.

Constructor & Destructor Documentation

◆ SYNC_QUEUE()

template<typename T>
SYNC_QUEUE< T >::SYNC_QUEUE ( )
inline

Definition at line 34 of file sync_queue.h.

Member Function Documentation

◆ clear()

template<typename T>
void SYNC_QUEUE< T >::clear ( )
inline

Clear the queue.

Definition at line 100 of file sync_queue.h.

References m_mutex, and m_queue.

◆ empty()

template<typename T>
bool SYNC_QUEUE< T >::empty ( ) const
inline

Return true if the queue is empty.

Definition at line 82 of file sync_queue.h.

References m_mutex, and m_queue.

◆ move_push()

template<typename T>
void SYNC_QUEUE< T >::move_push ( T && aValue)
inline

Move a value onto the queue.

Useful for e.g. unique_ptr.

Definition at line 50 of file sync_queue.h.

References m_mutex, m_queue, and T.

Referenced by DESIGN_BLOCK_LIST_IMPL::loadDesignBlocks(), and FOOTPRINT_LIST_IMPL::loadFootprints().

◆ pop()

template<typename T>
bool SYNC_QUEUE< T >::pop ( T & aReceiver)
inline

Pop a value if the queue into the provided variable.

If the queue is empty, the variable is not touched.

Returns
true if a value was popped.

Definition at line 63 of file sync_queue.h.

References m_mutex, m_queue, and T.

Referenced by DESIGN_BLOCK_LIST_IMPL::loadDesignBlocks(), and FOOTPRINT_LIST_IMPL::loadFootprints().

◆ push()

template<typename T>
void SYNC_QUEUE< T >::push ( T const & aValue)
inline

Push a value onto the queue.

Definition at line 41 of file sync_queue.h.

References m_mutex, m_queue, and T.

◆ size()

template<typename T>
size_t SYNC_QUEUE< T >::size ( ) const
inline

Return the size of the queue.

Definition at line 91 of file sync_queue.h.

References m_mutex, and m_queue.

Member Data Documentation

◆ m_mutex

template<typename T>
std::mutex SYNC_QUEUE< T >::m_mutex
mutableprivate

Definition at line 114 of file sync_queue.h.

Referenced by clear(), empty(), move_push(), pop(), push(), and size().

◆ m_queue

template<typename T>
std::queue<T> SYNC_QUEUE< T >::m_queue
private

Definition at line 113 of file sync_queue.h.

Referenced by clear(), empty(), move_push(), pop(), push(), and size().


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