Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:32:27

0001 // Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
0002 // Distributed under the MIT License (http://opensource.org/licenses/MIT)
0003 
0004 #pragma once
0005 
0006 #include <atomic>
0007 #include <utility>
0008 // null, no cost dummy "mutex" and dummy "atomic" int
0009 
0010 namespace spdlog {
0011 namespace details {
0012 struct null_mutex {
0013     void lock() const {}
0014     void unlock() const {}
0015 };
0016 
0017 struct null_atomic_int {
0018     int value;
0019     null_atomic_int() = default;
0020 
0021     explicit null_atomic_int(int new_value)
0022         : value(new_value) {}
0023 
0024     int load(std::memory_order = std::memory_order_relaxed) const { return value; }
0025 
0026     void store(int new_value, std::memory_order = std::memory_order_relaxed) { value = new_value; }
0027 
0028     int exchange(int new_value, std::memory_order = std::memory_order_relaxed) {
0029         std::swap(new_value, value);
0030         return new_value;  // return value before the call
0031     }
0032 };
0033 
0034 }  // namespace details
0035 }  // namespace spdlog