mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 23:00:42 +00:00
46 lines
736 B
C++
46 lines
736 B
C++
#include "GpVOSEventQueue.h"
|
|
|
|
#include <assert.h>
|
|
|
|
GpVOSEventQueue::GpVOSEventQueue()
|
|
: m_firstEvent(0)
|
|
, m_numEventsQueued(0)
|
|
{
|
|
}
|
|
|
|
GpVOSEventQueue::~GpVOSEventQueue()
|
|
{
|
|
}
|
|
|
|
const GpVOSEvent *GpVOSEventQueue::GetNext()
|
|
{
|
|
if (m_numEventsQueued)
|
|
return m_events + m_firstEvent;
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
void GpVOSEventQueue::DischargeOne()
|
|
{
|
|
assert(m_numEventsQueued > 0);
|
|
|
|
m_numEventsQueued--;
|
|
m_firstEvent++;
|
|
if (m_firstEvent == kMaxEvents)
|
|
m_firstEvent = 0;
|
|
}
|
|
|
|
GpVOSEvent *GpVOSEventQueue::QueueEvent()
|
|
{
|
|
if (m_numEventsQueued == kMaxEvents)
|
|
return nullptr;
|
|
|
|
size_t nextEvent = m_firstEvent + m_numEventsQueued;
|
|
if (nextEvent >= kMaxEvents)
|
|
nextEvent -= kMaxEvents;
|
|
|
|
m_numEventsQueued++;
|
|
|
|
return m_events + nextEvent;
|
|
}
|