Skip to content

Commit

Permalink
Expose the flusher thread object to user in order to allow setting of…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
cohdan authored Feb 14, 2024
1 parent 47b7e7c commit fe79bfc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/spdlog/details/periodic_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class SPDLOG_API periodic_worker {
}
});
}
std::thread &get_thread() { return worker_thread_; }
periodic_worker(const periodic_worker &) = delete;
periodic_worker &operator=(const periodic_worker &) = delete;
// stop the worker thread and join it
Expand Down
2 changes: 2 additions & 0 deletions include/spdlog/details/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class SPDLOG_API registry {
periodic_flusher_ = details::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 apply_all(const std::function<void(const std::shared_ptr<logger>)> &fun);
Expand Down

0 comments on commit fe79bfc

Please sign in to comment.