diff options
Diffstat (limited to 'archive/2025/summer/bsc_karidas/include/Writer.hpp')
| -rw-r--r-- | archive/2025/summer/bsc_karidas/include/Writer.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/archive/2025/summer/bsc_karidas/include/Writer.hpp b/archive/2025/summer/bsc_karidas/include/Writer.hpp new file mode 100644 index 000000000..3bc9e1672 --- /dev/null +++ b/archive/2025/summer/bsc_karidas/include/Writer.hpp @@ -0,0 +1,40 @@ +#ifndef WRITER_HPP +#define WRITER_HPP + +#include <thread> +#include <atomic> +#include <memory> +#include <vector> +#include "QueueItem.hpp" +#include "BufferQueue.hpp" +#include "SegmentedStorage.hpp" + +class Writer +{ +public: + explicit Writer(BufferQueue &queue, + std::shared_ptr<SegmentedStorage> storage, + size_t batchSize = 100, + bool useEncryption = true, + int m_compressionLevel = 9); + + ~Writer(); + + void start(); + void stop(); + bool isRunning() const; + +private: + void processLogEntries(); + + BufferQueue &m_queue; + std::shared_ptr<SegmentedStorage> m_storage; + std::unique_ptr<std::thread> m_writerThread; + std::atomic<bool> m_running{false}; + const size_t m_batchSize; + const bool m_useEncryption; + const int m_compressionLevel; + + BufferQueue::ConsumerToken m_consumerToken; +}; +#endif \ No newline at end of file |