2015-11-29 00:24:20 +08:00
|
|
|
//
|
|
|
|
// Copyright(c) 2015 Gabi Melman.
|
|
|
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
|
|
//
|
2014-11-01 09:20:54 +08:00
|
|
|
|
2014-10-11 02:36:32 +08:00
|
|
|
#pragma once
|
|
|
|
|
2016-04-10 06:37:11 +08:00
|
|
|
#include <atomic>
|
|
|
|
// null, no cost dummy "mutex" and dummy "atomic" int
|
2014-10-11 02:36:32 +08:00
|
|
|
|
2018-03-17 18:47:46 +08:00
|
|
|
namespace spdlog {
|
|
|
|
namespace details {
|
2014-10-11 02:36:32 +08:00
|
|
|
struct null_mutex
|
|
|
|
{
|
2014-12-21 08:47:04 +08:00
|
|
|
void lock() {}
|
|
|
|
void unlock() {}
|
|
|
|
bool try_lock()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-11 02:36:32 +08:00
|
|
|
};
|
2016-04-10 06:37:11 +08:00
|
|
|
|
|
|
|
struct null_atomic_int
|
|
|
|
{
|
2016-04-20 16:57:49 +08:00
|
|
|
int value;
|
|
|
|
null_atomic_int() = default;
|
2016-04-10 06:37:11 +08:00
|
|
|
|
2018-03-09 21:26:33 +08:00
|
|
|
explicit null_atomic_int(int val)
|
|
|
|
: value(val)
|
|
|
|
{
|
|
|
|
}
|
2016-04-10 06:37:11 +08:00
|
|
|
|
2016-04-20 16:57:49 +08:00
|
|
|
int load(std::memory_order) const
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
2016-04-10 06:37:11 +08:00
|
|
|
|
2016-04-20 16:57:49 +08:00
|
|
|
void store(int val)
|
|
|
|
{
|
|
|
|
value = val;
|
|
|
|
}
|
2016-04-10 06:37:11 +08:00
|
|
|
};
|
|
|
|
|
2018-03-17 18:47:46 +08:00
|
|
|
} // namespace details
|
|
|
|
} // namespace spdlog
|