OpenEV
Extending OpenCV to event-based vision
Loading...
Searching...
No Matches
concurrent_queue.hpp
Go to the documentation of this file.
1
6#ifndef OPENEV_CONTAINERS_CONCURRENT_QUEUE_HPP
7#define OPENEV_CONTAINERS_CONCURRENT_QUEUE_HPP
8
10#include <boost/lockfree/spsc_queue.hpp>
11#include <cstddef>
12
13namespace ev {
14[[maybe_unused]] constexpr bool USING_CONCURRENT_QUEUE_HPP = true;
15
37template <typename T>
38class ConcurrentQueue_ : public boost::lockfree::spsc_queue<Event_<T>> {
39public:
44 explicit ConcurrentQueue_(const std::size_t capacity) : boost::lockfree::spsc_queue<Event_<T>>{capacity}, capacity_{capacity} {}
45
49 inline void clear() {
50 while(boost::lockfree::spsc_queue<Event_<T>>::pop());
51 }
52
57 [[nodiscard]] inline bool empty() const {
58 return boost::lockfree::spsc_queue<Event_<T>>::read_available() == 0;
59 }
60
65 [[nodiscard]] inline bool full() const {
66 return boost::lockfree::spsc_queue<Event_<T>>::write_available() == 0;
67 }
68
73 [[nodiscard]] inline std::size_t size() const {
74 return boost::lockfree::spsc_queue<Event_<T>>::read_available();
75 }
76
81 [[nodiscard]] inline std::size_t capacity() const {
82 return capacity_;
83 }
84
85private:
86 std::size_t capacity_;
87};
88
94} // namespace ev
95
96#endif // OPENEV_CONTAINERS_CONCURRENT_QUEUE_HPP
This class extends boost::lockfree::spsc_queue to implement event queues that one thread fills while ...
Definition concurrent_queue.hpp:38
bool empty() const
Check if the queue holds no events.
Definition concurrent_queue.hpp:57
void clear()
Remove every event.
Definition concurrent_queue.hpp:49
ConcurrentQueue_(const std::size_t capacity)
Construct the queue.
Definition concurrent_queue.hpp:44
std::size_t capacity() const
Definition concurrent_queue.hpp:81
std::size_t size() const
Number of events in the queue.
Definition concurrent_queue.hpp:73
bool full() const
Check if the queue holds as many events as it can.
Definition concurrent_queue.hpp:65
This class extends cv::Point_<T> for event data. For more information, please refer here.
Definition types.hpp:86
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
Basic event-based vision structures based on OpenCV components.