CppLogging 1.0.5.0
C++ Logging Library
Loading...
Searching...
No Matches
async_wait_processor.h
Go to the documentation of this file.
1
9#ifndef CPPLOGGING_PROCESSORS_ASYNC_WAIT_PROCESSOR_H
10#define CPPLOGGING_PROCESSORS_ASYNC_WAIT_PROCESSOR_H
11
12#include "logging/processor.h"
13
14#include "threads/wait_batcher.h"
15
16#include <functional>
17
18namespace CppLogging {
19
21
36{
37public:
39
47 explicit AsyncWaitProcessor(const std::shared_ptr<Layout>& layout, bool auto_start = true, size_t capacity = 8192, size_t initial = 8192, const std::function<void ()>& on_thread_initialize = [](){}, const std::function<void ()>& on_thread_clenup = [](){});
50 virtual ~AsyncWaitProcessor();
51
54
55 // Implementation of Processor
56 bool Start() override;
57 bool Stop() override;
58 bool ProcessRecord(Record& record) override;
59 void Flush() override;
60
61private:
62 CppCommon::WaitBatcher<Record> _queue;
63 std::thread _thread;
64 std::function<void ()> _on_thread_initialize;
65 std::function<void ()> _on_thread_clenup;
66
67 bool EnqueueRecord(Record& record);
68 void ProcessThread(const std::function<void ()>& on_thread_initialize, const std::function<void ()>& on_thread_clenup);
69};
70
71} // namespace CppLogging
72
75#endif // CPPLOGGING_PROCESSORS_ASYNC_WAIT_PROCESSOR_H
Asynchronous wait logging processor.
AsyncWaitProcessor(AsyncWaitProcessor &&)=delete
AsyncWaitProcessor & operator=(const AsyncWaitProcessor &)=delete
AsyncWaitProcessor & operator=(AsyncWaitProcessor &&)=delete
AsyncWaitProcessor(const AsyncWaitProcessor &)=delete
bool ProcessRecord(Record &record) override
Process the given logging record through all child filters, layouts and appenders.
bool Start() override
Start the logging element.
void Flush() override
Flush the current logging processor.
bool Stop() override
Stop the logging element.
Logging processor interface.
Definition processor.h:31
std::shared_ptr< Layout > & layout() noexcept
Get the logging processor layout.
Definition processor.h:46
Logging record.
Definition record.h:37
C++ Logging project definitions.
Definition appender.h:15
Logging processor interface definition.