Zen 0.3.0
Loading...
Searching...
No Matches
ZEN_EventBuffer.h
1#pragma once
2
3#include <zen/zen_pch.h>
4
5#include <zen/events/ZEN_Event.h>
6
7namespace Zen {
8 class EventBuffer {
9 public:
10 EventBuffer(std::size_t capacity)
11 : m_buffer(std::unique_ptr<ZenEvent[]>(new ZenEvent[capacity])), m_maxCapacity(capacity) {}
12
13 ~EventBuffer() = default;
14
15 void enqueue(ZenEvent event);
16 ZenEvent dequeue();
17
18 void flush();
19 bool isEmpty() const;
20 bool isFull() const;
21
22 size_t capacity() const;
23 size_t size() const;
24
25 private:
26 std::unique_ptr<ZenEvent[]> m_buffer;
27 size_t m_head = 0;
28 size_t m_tail = 0;
29 const size_t m_maxCapacity;
30 bool m_full = false;
31 };
32} // namespace Zen