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< T > m_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 SYNC_QUEUE< T >::m_mutex, and SYNC_QUEUE< T >::m_queue.

Referenced by FOOTPRINT_LIST_IMPL::ReadFootprintFiles().

◆ 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 SYNC_QUEUE< T >::m_mutex, and SYNC_QUEUE< T >::m_queue.

Referenced by FOOTPRINT_LIST_IMPL::ReadFootprintFiles(), and PCM_TASK_MANAGER::RunQueue().

◆ 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 SYNC_QUEUE< T >::m_mutex, and SYNC_QUEUE< T >::m_queue.

Referenced by FOOTPRINT_LIST_IMPL::CatchErrors(), 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 SYNC_QUEUE< T >::m_mutex, and SYNC_QUEUE< T >::m_queue.

Referenced by FOOTPRINT_LIST_IMPL::loadFootprints(), FOOTPRINT_LIST_IMPL::loadLibs(), and PCM_TASK_MANAGER::RunQueue().

◆ push()

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

◆ size()

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

Member Data Documentation

◆ m_mutex

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

◆ m_queue

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

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