13 #ifndef __PROCESS_EVENT_QUEUE_HPP__ 14 #define __PROCESS_EVENT_QUEUE_HPP__ 27 #ifdef LOCK_FREE_EVENT_QUEUE 29 #endif // LOCK_FREE_EVENT_QUEUE 93 bool empty() {
return queue->empty(); }
96 size_t count() {
return queue->count<T>(); }
111 #ifndef LOCK_FREE_EVENT_QUEUE 114 synchronized (mutex) {
116 events.push_back(event);
126 Event*
event =
nullptr;
128 synchronized (mutex) {
129 if (events.size() > 0) {
130 Event*
event = events.front();
138 return CHECK_NOTNULL(event);
143 synchronized (mutex) {
144 return events.size() == 0;
150 synchronized (mutex) {
152 while (!events.empty()) {
153 Event*
event = events.front();
160 template <
typename T>
163 synchronized (mutex) {
164 return std::count_if(
167 [](
const Event* event) {
168 return event->is<T>();
176 synchronized (mutex) {
177 foreach (
Event* event, events) {
185 std::deque<Event*> events;
186 bool comissioned =
true;
187 #else // LOCK_FREE_EVENT_QUEUE 190 if (comissioned.load()) {
191 queue.enqueue(event);
200 return queue.dequeue();
205 return queue.empty();
210 comissioned.store(
true);
216 template <
typename T>
220 queue.for_each([&count](
Event* event) {
221 if (event->
is<T>()) {
231 queue.for_each([&array](
Event* event) {
244 std::atomic<bool> comissioned = ATOMIC_VAR_INIT(
true);
245 #endif // LOCK_FREE_EVENT_QUEUE 250 #endif // __PROCESS_EVENT_QUEUE_HPP__ Definition: mpsc_linked_queue.hpp:38
class process::EventQueue::Producer producer
size_t count()
Definition: event_queue.hpp:96
Definition: event_queue.hpp:68
class process::EventQueue::Consumer consumer
friend class Consumer
Definition: event_queue.hpp:109
bool is() const
Definition: event.hpp:68
bool empty()
Definition: event_queue.hpp:93
Definition: event_queue.hpp:73
EventQueue()
Definition: event_queue.hpp:71
std::vector< Value > values
Definition: json.hpp:203
void decomission()
Definition: event_queue.hpp:94
bool enqueue(Event *event)
Definition: event_queue.hpp:79
Definition: executor.hpp:48
Definition: event_queue.hpp:89
Event * dequeue()
Definition: event_queue.hpp:92