Expose the flusher thread object to user in order to allow setting of thread name and thread affinity when needed (#3009)

* Expose the flusher thread object to user in order to allow setting of thread name and thread affinity when needed

* Code review fix - periodic_worker thread getter should return a reference and not a pointer
This commit is contained in:
cohdan 2024-02-14 21:48:44 +02:00 committed by gabime
parent c577b54b06
commit dd8dc8105a
2 changed files with 3 additions and 0 deletions

View File

@ -40,6 +40,7 @@ public:
} }
}); });
} }
std::thread &get_thread() { return worker_thread_; }
periodic_worker(const periodic_worker &) = delete; periodic_worker(const periodic_worker &) = delete;
periodic_worker &operator=(const periodic_worker &) = delete; periodic_worker &operator=(const periodic_worker &) = delete;
// stop the worker thread and join it // stop the worker thread and join it

View File

@ -66,6 +66,8 @@ public:
periodic_flusher_ = std::make_unique<periodic_worker>(clbk, interval); periodic_flusher_ = std::make_unique<periodic_worker>(clbk, interval);
} }
std::unique_ptr<periodic_worker> &get_flusher() { std::lock_guard<std::mutex> lock(flusher_mutex_); return periodic_flusher_; }
void set_error_handler(err_handler handler); void set_error_handler(err_handler handler);
void apply_all(const std::function<void(const std::shared_ptr<logger>)> &fun); void apply_all(const std::function<void(const std::shared_ptr<logger>)> &fun);