Colobot
|
Global event queue. More...
#include <event.h>
Public Member Functions | |
CEventQueue () | |
Object's constructor. More... | |
~CEventQueue () | |
Object's destructor. More... | |
bool | IsEmpty () |
Checks if queue is empty. More... | |
bool | AddEvent (Event &&event) |
Adds an event to the queue. More... | |
Event | GetEvent () |
Removes and returns an event from queue front; if queue is empty, returns event of type EVENT_NULL. More... | |
Static Public Attributes | |
static const int | MAX_EVENT_QUEUE = 100 |
Constant maximum size of queue. More... | |
Protected Attributes | |
CSDLMutexWrapper | m_mutex |
Event | m_fifo [MAX_EVENT_QUEUE] |
int | m_head |
int | m_tail |
int | m_total |
Global event queue.
Provides an interface to a global FIFO queue with events (both system- and user-generated). The queue has a fixed maximum size but it should not be a problem.
This class is thread-safe
CEventQueue::CEventQueue | ( | ) |
Object's constructor.
CEventQueue::~CEventQueue | ( | ) |
Object's destructor.
bool CEventQueue::IsEmpty | ( | ) |
Checks if queue is empty.
bool CEventQueue::AddEvent | ( | Event && | event | ) |
Adds an event to the queue.
If the maximum size of queue has been reached, returns false
. Else, adds the event to the queue and returns true
.
Event CEventQueue::GetEvent | ( | ) |
Removes and returns an event from queue front; if queue is empty, returns event of type EVENT_NULL.
|
static |
Constant maximum size of queue.