diff options
author | Chris Robinson <[email protected]> | 2021-04-15 15:07:14 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-04-15 15:17:04 -0700 |
commit | 29cf7ebb752e00e116391a1df7a3ed0f49fdd193 (patch) | |
tree | 76b90d55cbcbae2bb3c04fc95aaef83161263ecc /al/listener.h | |
parent | 92148a3a044389863601b8b907bcfc69ff77b869 (diff) |
Make an inverted atomic flag type and use it
The inverted atomic flag replaces test_and_set+clear with test_and_clear+set,
essentially inverting the flag status. This makes more logical sense for
flagging dirty state, which is less confusing than flagging clean state. The
one caveat is ATOMIC_FLAG_INIT (or default construction in C++20) initializes
the state to true rather than false.
Diffstat (limited to 'al/listener.h')
-rw-r--r-- | al/listener.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/al/listener.h b/al/listener.h index 5f3ce3ec..f3332763 100644 --- a/al/listener.h +++ b/al/listener.h @@ -9,6 +9,7 @@ #include "AL/efx.h" #include "almalloc.h" +#include "atomic.h" struct ALlistener { @@ -19,9 +20,9 @@ struct ALlistener { float Gain{1.0f}; float mMetersPerUnit{AL_DEFAULT_METERS_PER_UNIT}; - std::atomic_flag PropsClean; + al::atomic_invflag mPropsDirty; - ALlistener() { PropsClean.test_and_set(std::memory_order_relaxed); } + ALlistener() { mPropsDirty.test_and_clear(std::memory_order_relaxed); } DISABLE_ALLOC() }; |