aboutsummaryrefslogtreecommitdiffstats
path: root/core/context.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/context.cpp')
-rw-r--r--core/context.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/core/context.cpp b/core/context.cpp
index 46f703a9..0fe50d25 100644
--- a/core/context.cpp
+++ b/core/context.cpp
@@ -27,19 +27,6 @@ ContextBase::ContextBase(DeviceBase *device) : mDevice{device}
ContextBase::~ContextBase()
{
- size_t count{0};
- ContextProps *cprops{mParams.ContextUpdate.exchange(nullptr, std::memory_order_relaxed)};
- if(std::unique_ptr<ContextProps> old{cprops})
- ++count;
-
- cprops = mFreeContextProps.exchange(nullptr, std::memory_order_acquire);
- while(std::unique_ptr<ContextProps> old{cprops})
- {
- cprops = old->next.load(std::memory_order_relaxed);
- ++count;
- }
- TRACE("Freed %zu context property object%s\n", count, (count==1)?"":"s");
-
if(std::unique_ptr<EffectSlotArray> curarray{mActiveAuxSlots.exchange(nullptr, std::memory_order_relaxed)})
std::destroy_n(curarray->end(), curarray->size());
@@ -47,7 +34,7 @@ ContextBase::~ContextBase()
if(mAsyncEvents)
{
- count = 0;
+ size_t count{0};
auto evt_vec = mAsyncEvents->getReadVector();
if(evt_vec.first.len > 0)
{
@@ -177,3 +164,24 @@ EffectSlot *ContextBase::getEffectSlot()
mEffectSlotClusters.emplace_back(std::move(clusterptr));
return mEffectSlotClusters.back()->data();
}
+
+
+void ContextBase::allocContextProps()
+{
+ static constexpr size_t clustersize{std::tuple_size_v<ContextPropsCluster::element_type>};
+
+ TRACE("Increasing allocated context properties to %zu\n",
+ (mContextPropClusters.size()+1) * clustersize);
+
+ auto clusterptr = std::make_unique<ContextPropsCluster::element_type>();
+ auto cluster = al::span{*clusterptr};
+ for(size_t i{1};i < clustersize;++i)
+ cluster[i-1].next.store(std::addressof(cluster[i]), std::memory_order_relaxed);
+ auto *newcluster = mContextPropClusters.emplace_back(std::move(clusterptr)).get();
+
+ ContextProps *oldhead{mFreeContextProps.load(std::memory_order_acquire)};
+ do {
+ newcluster->back().next.store(oldhead, std::memory_order_relaxed);
+ } while(mFreeContextProps.compare_exchange_weak(oldhead, newcluster->data(),
+ std::memory_order_acq_rel, std::memory_order_acquire) == false);
+}