OpenEV
Extending OpenCV to event-based vision
Toggle main menu visibility
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
9
#include "
openev/core/types.hpp
"
10
#include <boost/lockfree/spsc_queue.hpp>
11
#include <cstddef>
12
13
namespace
ev {
14
[[maybe_unused]]
constexpr
bool
USING_CONCURRENT_QUEUE_HPP =
true
;
15
37
template
<
typename
T>
38
class
ConcurrentQueue_
:
public
boost::lockfree::spsc_queue<Event_<T>> {
39
public
:
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
85
private
:
86
std::size_t capacity_;
87
};
88
89
using
ConcurrentQueuei
=
ConcurrentQueue_<int>
;
90
using
ConcurrentQueuel
=
ConcurrentQueue_<long>
;
91
using
ConcurrentQueuef
=
ConcurrentQueue_<float>
;
92
using
ConcurrentQueued
=
ConcurrentQueue_<double>
;
93
using
ConcurrentQueue
=
ConcurrentQueuei
;
94
}
// namespace ev
95
96
#endif
// OPENEV_CONTAINERS_CONCURRENT_QUEUE_HPP
ev::ConcurrentQueue_
This class extends boost::lockfree::spsc_queue to implement event queues that one thread fills while ...
Definition
concurrent_queue.hpp:38
ev::ConcurrentQueue_::empty
bool empty() const
Check if the queue holds no events.
Definition
concurrent_queue.hpp:57
ev::ConcurrentQueue_::clear
void clear()
Remove every event.
Definition
concurrent_queue.hpp:49
ev::ConcurrentQueue_::ConcurrentQueue_
ConcurrentQueue_(const std::size_t capacity)
Construct the queue.
Definition
concurrent_queue.hpp:44
ev::ConcurrentQueue_< int >::capacity
std::size_t capacity() const
Definition
concurrent_queue.hpp:81
ev::ConcurrentQueue_::size
std::size_t size() const
Number of events in the queue.
Definition
concurrent_queue.hpp:73
ev::ConcurrentQueue_::full
bool full() const
Check if the queue holds as many events as it can.
Definition
concurrent_queue.hpp:65
ev::Event_
This class extends cv::Point_<T> for event data. For more information, please refer here.
Definition
types.hpp:86
ev::ConcurrentQueuel
ConcurrentQueue_< long > ConcurrentQueuel
Definition
concurrent_queue.hpp:90
ev::ConcurrentQueued
ConcurrentQueue_< double > ConcurrentQueued
Definition
concurrent_queue.hpp:92
ev::ConcurrentQueue
ConcurrentQueuei ConcurrentQueue
Definition
concurrent_queue.hpp:93
ev::ConcurrentQueuei
ConcurrentQueue_< int > ConcurrentQueuei
Definition
concurrent_queue.hpp:89
ev::ConcurrentQueuef
ConcurrentQueue_< float > ConcurrentQueuef
Definition
concurrent_queue.hpp:91
types.hpp
Basic event-based vision structures based on OpenCV components.
modules
containers
include
openev
containers
concurrent_queue.hpp
Generated by
1.17.0