VoidLoader/VoidLoaderCore/pipeline/head There was a failure building this commit
Signed-off-by: Faumaray <faumaray@gmail.com>
36 lines
623 B
C++
36 lines
623 B
C++
#pragma once
|
|
#include <Logging/Sink.hpp>
|
|
#include <Logging/Message.hpp>
|
|
#include <condition_variable>
|
|
#include <thread>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <queue>
|
|
#include <stop_token>
|
|
|
|
namespace vl::logging {
|
|
|
|
class AsyncWorker {
|
|
public:
|
|
static AsyncWorker& instance();
|
|
|
|
struct Item {
|
|
std::shared_ptr<Sink> sink;
|
|
Message msg;
|
|
};
|
|
|
|
void enqueue(Item&& item);
|
|
|
|
private:
|
|
AsyncWorker();
|
|
~AsyncWorker();
|
|
void run(std::stop_token st);
|
|
|
|
std::mutex mtx_;
|
|
std::condition_variable_any cv_;
|
|
std::queue<Item> queue_;
|
|
std::jthread thread_;
|
|
};
|
|
|
|
} // namespace vl::log
|