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 | |
10 | namespace spdlog { |
11 | namespace details { |
12 | |
13 | // stop the worker thread and join it |
14 | SPDLOG_INLINE periodic_worker::~periodic_worker() |
15 | { |
16 | if (worker_thread_.joinable()) |
17 | { |
18 | { |
19 | std::lock_guard<std::mutex> lock(mutex_); |
20 | active_ = false; |
21 | } |
22 | cv_.notify_one(); |
23 | worker_thread_.join(); |
24 | } |
25 | } |
26 | |
27 | } // namespace details |
28 | } // namespace spdlog |
29 | |