diff options
author | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-07-07 21:31:41 +0100 |
---|---|---|
committer | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-07-07 21:31:41 +0100 |
commit | 2ae34b67e36b8ba05132d481876eb4ed7a826283 (patch) | |
tree | 63f44c8e2dcdc959d7a5317a3a7b36efedbd7d38 /NorthstarDLL/include/spdlog/details/backtracer-inl.h | |
parent | 3406de7aaaf52cbef20b1549f2d7da0255d30f51 (diff) | |
download | NorthstarLauncher-2ae34b67e36b8ba05132d481876eb4ed7a826283.tar.gz NorthstarLauncher-2ae34b67e36b8ba05132d481876eb4ed7a826283.zip |
almost fully replaced hooking lib
Diffstat (limited to 'NorthstarDLL/include/spdlog/details/backtracer-inl.h')
-rw-r--r-- | NorthstarDLL/include/spdlog/details/backtracer-inl.h | 138 |
1 files changed, 69 insertions, 69 deletions
diff --git a/NorthstarDLL/include/spdlog/details/backtracer-inl.h b/NorthstarDLL/include/spdlog/details/backtracer-inl.h index 21553c26..00a4461e 100644 --- a/NorthstarDLL/include/spdlog/details/backtracer-inl.h +++ b/NorthstarDLL/include/spdlog/details/backtracer-inl.h @@ -1,69 +1,69 @@ -// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) - -#pragma once - -#ifndef SPDLOG_HEADER_ONLY -#include <spdlog/details/backtracer.h> -#endif -namespace spdlog { -namespace details { -SPDLOG_INLINE backtracer::backtracer(const backtracer &other) -{ - std::lock_guard<std::mutex> lock(other.mutex_); - enabled_ = other.enabled(); - messages_ = other.messages_; -} - -SPDLOG_INLINE backtracer::backtracer(backtracer &&other) SPDLOG_NOEXCEPT -{ - std::lock_guard<std::mutex> lock(other.mutex_); - enabled_ = other.enabled(); - messages_ = std::move(other.messages_); -} - -SPDLOG_INLINE backtracer &backtracer::operator=(backtracer other) -{ - std::lock_guard<std::mutex> lock(mutex_); - enabled_ = other.enabled(); - messages_ = std::move(other.messages_); - return *this; -} - -SPDLOG_INLINE void backtracer::enable(size_t size) -{ - std::lock_guard<std::mutex> lock{mutex_}; - enabled_.store(true, std::memory_order_relaxed); - messages_ = circular_q<log_msg_buffer>{size}; -} - -SPDLOG_INLINE void backtracer::disable() -{ - std::lock_guard<std::mutex> lock{mutex_}; - enabled_.store(false, std::memory_order_relaxed); -} - -SPDLOG_INLINE bool backtracer::enabled() const -{ - return enabled_.load(std::memory_order_relaxed); -} - -SPDLOG_INLINE void backtracer::push_back(const log_msg &msg) -{ - std::lock_guard<std::mutex> lock{mutex_}; - messages_.push_back(log_msg_buffer{msg}); -} - -// pop all items in the q and apply the given fun on each of them. -SPDLOG_INLINE void backtracer::foreach_pop(std::function<void(const details::log_msg &)> fun) -{ - std::lock_guard<std::mutex> lock{mutex_}; - while (!messages_.empty()) - { - auto &front_msg = messages_.front(); - fun(front_msg); - messages_.pop_front(); - } -} -} // namespace details -} // namespace spdlog +// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
+// Distributed under the MIT License (http://opensource.org/licenses/MIT)
+
+#pragma once
+
+#ifndef SPDLOG_HEADER_ONLY
+#include <spdlog/details/backtracer.h>
+#endif
+namespace spdlog {
+namespace details {
+SPDLOG_INLINE backtracer::backtracer(const backtracer &other)
+{
+ std::lock_guard<std::mutex> lock(other.mutex_);
+ enabled_ = other.enabled();
+ messages_ = other.messages_;
+}
+
+SPDLOG_INLINE backtracer::backtracer(backtracer &&other) SPDLOG_NOEXCEPT
+{
+ std::lock_guard<std::mutex> lock(other.mutex_);
+ enabled_ = other.enabled();
+ messages_ = std::move(other.messages_);
+}
+
+SPDLOG_INLINE backtracer &backtracer::operator=(backtracer other)
+{
+ std::lock_guard<std::mutex> lock(mutex_);
+ enabled_ = other.enabled();
+ messages_ = std::move(other.messages_);
+ return *this;
+}
+
+SPDLOG_INLINE void backtracer::enable(size_t size)
+{
+ std::lock_guard<std::mutex> lock{mutex_};
+ enabled_.store(true, std::memory_order_relaxed);
+ messages_ = circular_q<log_msg_buffer>{size};
+}
+
+SPDLOG_INLINE void backtracer::disable()
+{
+ std::lock_guard<std::mutex> lock{mutex_};
+ enabled_.store(false, std::memory_order_relaxed);
+}
+
+SPDLOG_INLINE bool backtracer::enabled() const
+{
+ return enabled_.load(std::memory_order_relaxed);
+}
+
+SPDLOG_INLINE void backtracer::push_back(const log_msg &msg)
+{
+ std::lock_guard<std::mutex> lock{mutex_};
+ messages_.push_back(log_msg_buffer{msg});
+}
+
+// pop all items in the q and apply the given fun on each of them.
+SPDLOG_INLINE void backtracer::foreach_pop(std::function<void(const details::log_msg &)> fun)
+{
+ std::lock_guard<std::mutex> lock{mutex_};
+ while (!messages_.empty())
+ {
+ auto &front_msg = messages_.front();
+ fun(front_msg);
+ messages_.pop_front();
+ }
+}
+} // namespace details
+} // namespace spdlog
|