34 lines
641 B
C++
34 lines
641 B
C++
//
|
|
// Created by Kirill Zhukov on 20.04.2025.
|
|
//
|
|
|
|
#ifndef SHAREDCOMMANDQUEUE_H
|
|
#define SHAREDCOMMANDQUEUE_H
|
|
|
|
#include "Command.h"
|
|
#include "utils/datastructures/LFCircullarBuffer.h"
|
|
#include <atomic>
|
|
#include <cstdint>
|
|
|
|
namespace usub::core
|
|
{
|
|
constexpr size_t SHM_QUEUE_CAPACITY = 1024;
|
|
|
|
struct SharedCommandQueue
|
|
{
|
|
SharedCommandQueue();
|
|
|
|
explicit SharedCommandQueue(size_t cap);
|
|
|
|
bool try_push(const Command& cmd) const;
|
|
|
|
std::optional<Command> try_pop() const;
|
|
|
|
size_t capacity;
|
|
std::unique_ptr<utils::LockFreeRingBuffer<Command>> queue;
|
|
};
|
|
}
|
|
|
|
|
|
#endif //SHAREDCOMMANDQUEUE_H
|