Photon 1.0.0
Loading...
Searching...
No Matches
backtracer-inl.h
Go to the documentation of this file.
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
8#endif
9namespace spdlog
10{
11 namespace details
12 {
14 {
15 std::lock_guard<std::mutex> lock(other.mutex_);
16 enabled_ = other.enabled();
17 messages_ = other.messages_;
18 }
19
21 {
22 std::lock_guard<std::mutex> lock(other.mutex_);
23 enabled_ = other.enabled();
24 messages_ = std::move(other.messages_);
25 }
26
28 {
29 std::lock_guard<std::mutex> lock(mutex_);
30 enabled_ = other.enabled();
31 messages_ = std::move(other.messages_);
32 return *this;
33 }
34
36 {
37 std::lock_guard<std::mutex> lock{mutex_};
38 enabled_.store(true, std::memory_order_relaxed);
40 }
41
43 {
44 std::lock_guard<std::mutex> lock{mutex_};
45 enabled_.store(false, std::memory_order_relaxed);
46 }
47
49 {
50 return enabled_.load(std::memory_order_relaxed);
51 }
52
54 {
55 std::lock_guard<std::mutex> lock{mutex_};
57 }
58
60 {
61 std::lock_guard<std::mutex> lock{mutex_};
62 return messages_.empty();
63 }
64
65 // pop all items in the q and apply the given fun on each of them.
66 SPDLOG_INLINE void backtracer::foreach_pop(std::function<void(const details::log_msg&)> fun)
67 {
68 std::lock_guard<std::mutex> lock{mutex_};
69 while (!messages_.empty())
70 {
71 auto& front_msg = messages_.front();
72 fun(front_msg);
73 messages_.pop_front();
74 }
75 }
76 } // namespace details
77} // namespace spdlog
Definition backtracer.h:21
void disable()
Definition backtracer-inl.h:42
void push_back(const log_msg &msg)
Definition backtracer-inl.h:53
backtracer & operator=(backtracer other)
Definition backtracer-inl.h:27
std::atomic< bool > enabled_
Definition backtracer.h:23
std::mutex mutex_
Definition backtracer.h:22
bool enabled() const
Definition backtracer-inl.h:48
void enable(size_t size)
Definition backtracer-inl.h:35
bool empty() const
Definition backtracer-inl.h:59
void foreach_pop(std::function< void(const details::log_msg &)> fun)
Definition backtracer-inl.h:66
circular_q< log_msg_buffer > messages_
Definition backtracer.h:24
Definition circular_q.h:16
void push_back(T &&item)
Definition circular_q.h:53
Definition log_msg_buffer.h:17
#define SPDLOG_NOEXCEPT
Definition common.h:69
#define SPDLOG_INLINE
Definition common.h:47
Definition async.h:26
Definition log_msg.h:14
annotation details
Definition tag_strings.h:125