memgraph/include/logging/logs/async_log.hpp
2016-08-19 01:28:37 +01:00

24 lines
402 B
C++

#pragma once
#include <thread>
#include "logging/log.hpp"
#include "data_structures/queue/mpsc_queue.hpp"
class AsyncLog : public Log
{
public:
~AsyncLog();
protected:
void emit(Record::uptr) override;
std::string type() override;
private:
lockfree::MpscQueue<Record> records;
std::atomic<bool> alive {true};
std::thread worker {[this]() { work(); }};
void work();
};