// // Created by Kirill Zhukov on 20.04.2025. // #ifndef COMMAND_H #define COMMAND_H #include #include #include "utils/hash/Hash128.h" namespace usub::core { enum class OperationType : uint8_t { PUT = 0, DELETE = 1, FIND = 2 }; struct alignas(64) Command { Command() : ready(0), op(OperationType::PUT), key(), value_size(0), value() { } Command(const Command& other) : ready(other.ready.load(std::memory_order_relaxed)), // копируем ready явно op(other.op), key(other.key), value_size(other.value_size), value() { std::memcpy(value, other.value, other.value_size); } Command(Command&& other) noexcept : ready(other.ready.load(std::memory_order_relaxed)), op(other.op), key(other.key), value_size(other.value_size), value() { std::memcpy(value, other.value, other.value_size); } Command& operator=(const Command& other) { if (this != &other) { ready.store(other.ready.load(std::memory_order_relaxed), std::memory_order_relaxed); op = other.op; key = other.key; value_size = other.value_size; std::memcpy(value, other.value, other.value_size); } return *this; } Command& operator=(Command&& other) noexcept { if (this != &other) { ready.store(other.ready.load(std::memory_order_relaxed), std::memory_order_relaxed); op = other.op; key = other.key; value_size = other.value_size; std::memcpy(value, other.value, other.value_size); } return *this; } std::atomic ready; OperationType op; utils::Hash128 key; uint32_t value_size; char value[1024]; }; } #endif // COMMAND_H