Photon 1.0.0
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
11{
12 namespace details
13 {
15 {
16 void lock() const
17 {
18 }
19 void unlock() const
20 {
21 }
22 };
23
25 {
26 int value;
27 null_atomic_int() = default;
28
29 explicit null_atomic_int(int new_value)
30 : value(new_value)
31 {
32 }
33
34 int load(std::memory_order = std::memory_order_relaxed) const
35 {
36 return value;
37 }
38
39 void store(int new_value, std::memory_order = std::memory_order_relaxed)
40 {
41 value = new_value;
42 }
43
44 int exchange(int new_value, std::memory_order = std::memory_order_relaxed)
45 {
46 std::swap(new_value, value);
47 return new_value; // return value before the call
48 }
49 };
50
51 } // namespace details
52} // namespace spdlog
Definition core.h:1598
Definition async.h:26
Definition null_mutex.h:25
int exchange(int new_value, std::memory_order=std::memory_order_relaxed)
Definition null_mutex.h:44
int load(std::memory_order=std::memory_order_relaxed) const
Definition null_mutex.h:34
null_atomic_int(int new_value)
Definition null_mutex.h:29
int value
Definition null_mutex.h:26
void store(int new_value, std::memory_order=std::memory_order_relaxed)
Definition null_mutex.h:39
Definition null_mutex.h:15
void lock() const
Definition null_mutex.h:16
void unlock() const
Definition null_mutex.h:19
annotation details
Definition tag_strings.h:125