1// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
2// Distributed under the MIT License (http://opensource.org/licenses/MIT)
3
4#pragma once
5
6#ifndef SPDLOG_HEADER_ONLY
7 #include <spdlog/details/periodic_worker.h>
8#endif
9
10namespace spdlog {
11namespace details {
12
13// stop the worker thread and join it
14SPDLOG_INLINE periodic_worker::~periodic_worker() {
15 if (worker_thread_.joinable()) {
16 {
17 std::lock_guard<std::mutex> lock(mutex_);
18 active_ = false;
19 }
20 cv_.notify_one();
21 worker_thread_.join();
22 }
23}
24
25} // namespace details
26} // namespace spdlog
27