This commit is contained in:
2026-11-13 18:31:07 +06:00
parent 3a16ac0c0e
commit bb258484df
7 changed files with 153 additions and 9 deletions
+29
View File
@@ -0,0 +1,29 @@
#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);
buffer.fill(Command::None);
}
bool push(Command command);
bool pop(Command& command);
private:
std::array<Command, 64> buffer;
std::atomic<std::size_t> head;
std::atomic<std::size_t> tail;
};
#endif