1#include <zen/events/ZEN_Event.h>
2#include <zen/events/ZEN_EventBuffer.h>
6 void EventBuffer::enqueue(
ZenEvent event) {
7 m_buffer[m_head] = event;
10 m_tail = (m_tail + 1) % m_maxCapacity;
13 m_head = (m_head + 1) % m_maxCapacity;
14 m_full = m_head == m_tail;
22 ZenEvent
event = m_buffer[m_tail];
25 m_tail = (m_tail + 1) % m_maxCapacity;
30 void EventBuffer::flush() {
35 bool EventBuffer::isEmpty()
const {
return (!m_full && (m_head == m_tail)); }
36 bool EventBuffer::isFull()
const {
return m_full; }
38 size_t EventBuffer::capacity()
const {
return m_maxCapacity; }
39 size_t EventBuffer::size()
const {
40 size_t size = m_maxCapacity;
43 if (m_head >= m_tail) {
44 size = m_head - m_tail;
46 size = m_maxCapacity + m_head - m_tail;