mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Reformat all the things. Have fun with merge conflicts.
This commit is contained in:
@ -19,44 +19,27 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace Common {
|
||||
|
||||
namespace Common
|
||||
{
|
||||
class Flag final
|
||||
{
|
||||
public:
|
||||
// Declared as explicit since we do not want "= true" to work on a flag
|
||||
// object - it should be made explicit that a flag is *not* a normal
|
||||
// variable.
|
||||
explicit Flag(bool initial_value = false) : m_val(initial_value) {}
|
||||
|
||||
void Set(bool val = true)
|
||||
{
|
||||
m_val.store(val);
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
Set(false);
|
||||
}
|
||||
|
||||
bool IsSet() const
|
||||
{
|
||||
return m_val.load();
|
||||
}
|
||||
|
||||
bool TestAndSet(bool val = true)
|
||||
{
|
||||
bool expected = !val;
|
||||
return m_val.compare_exchange_strong(expected, val);
|
||||
}
|
||||
|
||||
bool TestAndClear()
|
||||
{
|
||||
return TestAndSet(false);
|
||||
}
|
||||
// Declared as explicit since we do not want "= true" to work on a flag
|
||||
// object - it should be made explicit that a flag is *not* a normal
|
||||
// variable.
|
||||
explicit Flag(bool initial_value = false) : m_val(initial_value) {}
|
||||
void Set(bool val = true) { m_val.store(val); }
|
||||
void Clear() { Set(false); }
|
||||
bool IsSet() const { return m_val.load(); }
|
||||
bool TestAndSet(bool val = true)
|
||||
{
|
||||
bool expected = !val;
|
||||
return m_val.compare_exchange_strong(expected, val);
|
||||
}
|
||||
|
||||
bool TestAndClear() { return TestAndSet(false); }
|
||||
private:
|
||||
std::atomic_bool m_val;
|
||||
std::atomic_bool m_val;
|
||||
};
|
||||
|
||||
} // namespace Common
|
||||
|
Reference in New Issue
Block a user