spdlog
Loading...
Searching...
No Matches
null_mutex.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#include <atomic>
7#include <utility>
8// null, no cost dummy "mutex" and dummy "atomic" int
9
10namespace spdlog {
11namespace details {
13{
14 void lock() const {}
15 void unlock() const {}
16 bool try_lock() const
17 {
18 return true;
19 }
20};
21
23{
24 int value;
25 null_atomic_int() = default;
26
27 explicit null_atomic_int(int new_value)
28 : value(new_value)
29 {}
30
32 {
33 return value;
34 }
35
37 {
38 value = new_value;
39 }
40
42 {
43 std::swap(new_value, value);
44 return new_value; // return value before the call
45 }
46};
47
48} // namespace details
49} // namespace spdlog
Definition core.h:1120
T make_shared(T... args)
Definition async.h:25
int exchange(int new_value, std::memory_order=std::memory_order_relaxed)
Definition null_mutex.h:41
int load(std::memory_order=std::memory_order_relaxed) const
Definition null_mutex.h:31
void store(int new_value, std::memory_order=std::memory_order_relaxed)
Definition null_mutex.h:36
T swap(T... args)