eventqueue.h
#ifndef XF_EVENT_QUEUE_DEFAULT_QT_H
#define XF_EVENT_QUEUE_DEFAULT_QT_H
#include "config/xf-config.h"
#if (USE_XF_IDF_QT_EVENT_QUEUE_CLASS != 0)
#include <stdint.h>
#include <QMutex>
#include <QWaitCondition>
#include <QQueue>
#include "xf/interface/eventqueue.h"
class XFEventQueue : public interface::XFEventQueue
{
public:
XFEventQueue();
~XFEventQueue() override;
// XFEventQueue interface implementation
public:
bool empty() const override;
bool push(const XFEvent * pEvent, bool fromISR = false) override;
const XFEvent * front() override;
void pop() override;
bool pend() override;
protected:
typedef QQueue<const XFEvent *> EventQueue;
QMutex mutex_;
QWaitCondition newEvents_;
EventQueue queue_;
};
// end of port_idf_qt group
#endif // USE_XF_IDF_QT_EVENT_QUEUE_CLASS
#endif // XF_EVENT_QUEUE_DEFAULT_QT_H
XFEvent
Base class for all types of events and timeouts.
Definition: event.h:23
XFEventQueue
Default Qt implementation for the XFEventQueue interface.
Definition: eventqueue.h:22
XFEventQueue::empty
bool empty() const override
Returns true if no event is in the queue.
Definition: eventqueue.cpp:19
XFEventQueue::newEvents_
QWaitCondition newEvents_
Wait condition to let thread wait until a new event arrives.
Definition: eventqueue.h:39
XFEventQueue::queue_
EventQueue queue_
Internal queue holding the events.
Definition: eventqueue.h:40
XFEventQueue::pop
void pop() override
Pops the next event from the queue.
Definition: eventqueue.cpp:39
XFEventQueue::pend
bool pend() override
Wait for the next event to arrive. Returns true if an event is in the queue.
Definition: eventqueue.cpp:45
XFEventQueue::mutex_
QMutex mutex_
Mutex (non-recursive) protecting access to _queue.
Definition: eventqueue.h:38
XFEventQueue::front
const XFEvent * front() override
Returns pointer to next event to pop.
Definition: eventqueue.cpp:34
XFEventQueue::push
bool push(const XFEvent *pEvent, bool fromISR=false) override
Pushes the given event onto the queue. Returns false if the event could not be pushed.
Definition: eventqueue.cpp:24
XFEventQueue::EventQueue
QQueue< const XFEvent * > EventQueue
Type of the event queue.
Definition: eventqueue.h:36
interface::XFEventQueue
Interface to be implemented by the event queue.
Definition: eventqueue.h:12