Files
osc/include/spsc_queue.hpp
T

30 lines
558 B
C++
Raw Normal View History

2026-11-13 18:31:07 +06:00
#ifndef SPSC_QUEUE
#define SPSC_QUEUE
#include <atomic>
#include <array>
#include <cstddef>
#include "../include/command.hpp"
class SpscQueue{
public:
SpscQueue(){
head.store(0, std::memory_order_relaxed);
tail.store(0, std::memory_order_relaxed);
2026-11-13 23:59:25 +06:00
buffer.fill({CommandType::None, 0, 0});
2026-11-13 18:31:07 +06:00
}
2026-11-13 23:59:25 +06:00
bool push(const Command&);
bool pop(Command&);
2026-11-13 18:31:07 +06:00
private:
std::array<Command, 64> buffer;
std::atomic<std::size_t> head;
std::atomic<std::size_t> tail;
};
#endif