Clean context

This commit is contained in:
gabime 2024-12-06 15:16:43 +02:00
parent 79df003092
commit f6a964d52e

View File

@ -29,26 +29,25 @@ public:
context(const context &) = delete; context(const context &) = delete;
context &operator=(const context &) = delete; context &operator=(const context &) = delete;
std::shared_ptr<logger> global_logger(); [[nodiscard]] std::shared_ptr<logger> global_logger();
// Return raw ptr to the global logger. // Return raw ptr to the global logger.
// To be used directly by the spdlog global api (e.g. spdlog::info) // To be used directly by the spdlog global api (e.g. spdlog::info)
// This make the global API faster, but cannot be used concurrently with set_global_logger(). // This make the global API faster, but cannot be used concurrently with set_global_logger().
// e.g do not call set_global_logger() from one thread while calling spdlog::info() from // e.g do not call set_global_logger() from one thread while calling spdlog::info() from
// another. // another.
logger *global_logger_raw() const noexcept; [[nodiscard]] logger *global_logger_raw() const noexcept;
// set logger instance. // set logger instance.
void set_logger(std::shared_ptr<logger> new_logger); void set_logger(std::shared_ptr<logger> new_logger);
void set_tp(std::shared_ptr<thread_pool> tp); void set_tp(std::shared_ptr<thread_pool> tp);
std::shared_ptr<thread_pool> get_tp(); [[nodiscard]] std::shared_ptr<thread_pool> get_tp();
// clean all resources // clean all resources
void shutdown(); void shutdown();
std::recursive_mutex &tp_mutex(); [[nodiscard]] std::recursive_mutex &tp_mutex();
private: private:
std::recursive_mutex tp_mutex_; std::recursive_mutex tp_mutex_;