aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2024-01-01 10:53:52 -0800
committerChris Robinson <[email protected]>2024-01-01 10:53:52 -0800
commitaa23d619324ca7e9d51829a2cc5d276c98305eb9 (patch)
tree59aba746e891409b01655c332a5aa4887217176b /core
parenta03bfe04c16fa2df0ac86cde53154ca99c18ad53 (diff)
Make and use a (simple) atomic unique_ptr
Diffstat (limited to 'core')
-rw-r--r--core/context.cpp4
-rw-r--r--core/context.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/core/context.cpp b/core/context.cpp
index b969583b..cb00ae70 100644
--- a/core/context.cpp
+++ b/core/context.cpp
@@ -52,7 +52,7 @@ ContextBase::~ContextBase()
if(std::unique_ptr<EffectSlotArray> curarray{mActiveAuxSlots.exchange(nullptr, std::memory_order_relaxed)})
std::destroy_n(curarray->end(), curarray->size());
- std::unique_ptr<ContextBase::VoiceArray>{mVoices.exchange(nullptr, std::memory_order_relaxed)};
+ mVoices.store(nullptr, std::memory_order_relaxed);
if(mAsyncEvents)
{
@@ -142,7 +142,7 @@ void ContextBase::allocVoices(size_t addcount)
voice_iter = std::transform(cluster->begin(), cluster->end(), voice_iter,
[](Voice &voice) noexcept -> Voice* { return &voice; });
- if(std::unique_ptr<ContextBase::VoiceArray> oldvoices{mVoices.exchange(newarray.release(), std::memory_order_acq_rel)})
+ if(auto oldvoices = mVoices.exchange(std::move(newarray), std::memory_order_acq_rel))
std::ignore = mDevice->waitForMix();
}
diff --git a/core/context.h b/core/context.h
index 0b830205..6fc1ed5d 100644
--- a/core/context.h
+++ b/core/context.h
@@ -112,7 +112,7 @@ struct ContextBase {
ContextParams mParams;
using VoiceArray = al::FlexArray<Voice*>;
- std::atomic<VoiceArray*> mVoices{};
+ al::atomic_unique_ptr<VoiceArray> mVoices{};
std::atomic<size_t> mActiveVoiceCount{};
void allocVoices(size_t addcount);