30 lines
595 B
C++
30 lines
595 B
C++
//
|
|
// Created by Kirill Zhukov on 20.04.2025.
|
|
//
|
|
|
|
#include "SharedCommandQueue.h"
|
|
|
|
namespace usub::core
|
|
{
|
|
SharedCommandQueue::SharedCommandQueue()
|
|
: SharedCommandQueue(1024)
|
|
{
|
|
}
|
|
|
|
SharedCommandQueue::SharedCommandQueue(size_t cap)
|
|
: capacity(cap),
|
|
queue(std::make_unique<utils::LockFreeRingBuffer<Command>>(cap))
|
|
{
|
|
}
|
|
|
|
bool SharedCommandQueue::try_push(const Command& cmd) const
|
|
{
|
|
return this->queue->push(cmd);
|
|
}
|
|
|
|
std::optional<Command> SharedCommandQueue::try_pop() const
|
|
{
|
|
return this->queue->pop();
|
|
}
|
|
}
|