OpenEV
Extending OpenCV to event-based vision
Loading...
Searching...
No Matches
ev::ConcurrentQueue_< T > Class Template Reference

This class extends boost::lockfree::spsc_queue to implement event queues that one thread fills while another one empties, with no locks. For more information, please refer here. More...

#include <concurrent_queue.hpp>

Inheritance diagram for ev::ConcurrentQueue_< T >:

Public Member Functions

 ConcurrentQueue_ (const std::size_t capacity)
 Construct the queue.
void clear ()
 Remove every event.
bool empty () const
 Check if the queue holds no events.
bool full () const
 Check if the queue holds as many events as it can.
std::size_t size () const
 Number of events in the queue.
std::size_t capacity () const
 Number of events the queue can hold.

Detailed Description

template<typename T>
class ev::ConcurrentQueue_< T >

This class extends boost::lockfree::spsc_queue to implement event queues that one thread fills while another one empties, with no locks. For more information, please refer here.

Concurrent event queues inherit all the properties from boost single-producer single-consumer queues, so they are FIFO structures of fixed capacity that cannot be iterated. push() and full() belong to the thread that fills the queue, and front(), pop() and clear() to the thread that empties it. empty(), size() and capacity() can be used by both.

Note
Unlike event circular buffers, a full queue does not overwrite its oldest event: push() returns false and the event is not added, so no event is ever lost between the two threads.
At most one thread may push and at most one thread may pop.

Analogously to OpenCV library, the following aliases are defined for convenience:

ConcurrentQueue_(const std::size_t capacity)
Construct the queue.
Definition concurrent_queue.hpp:44
ConcurrentQueue_< long > ConcurrentQueuel
Definition concurrent_queue.hpp:90
ConcurrentQueue_< double > ConcurrentQueued
Definition concurrent_queue.hpp:92
ConcurrentQueuei ConcurrentQueue
Definition concurrent_queue.hpp:93
ConcurrentQueue_< int > ConcurrentQueuei
Definition concurrent_queue.hpp:89
ConcurrentQueue_< float > ConcurrentQueuef
Definition concurrent_queue.hpp:91

Constructor & Destructor Documentation

◆ ConcurrentQueue_()

template<typename T>
ev::ConcurrentQueue_< T >::ConcurrentQueue_ ( const std::size_t capacity)
inlineexplicit

Construct the queue.

Parameters
capacityNumber of events the queue can hold

Member Function Documentation

◆ capacity()

template<typename T>
std::size_t ev::ConcurrentQueue_< T >::capacity ( ) const
inlinenodiscard

Number of events the queue can hold.

Returns
Capacity

◆ empty()

template<typename T>
bool ev::ConcurrentQueue_< T >::empty ( ) const
inlinenodiscard

Check if the queue holds no events.

Returns
True if empty

◆ full()

template<typename T>
bool ev::ConcurrentQueue_< T >::full ( ) const
inlinenodiscard

Check if the queue holds as many events as it can.

Returns
True if full

◆ size()

template<typename T>
std::size_t ev::ConcurrentQueue_< T >::size ( ) const
inlinenodiscard

Number of events in the queue.

Returns
Number of events

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