aboutsummaryrefslogtreecommitdiffstats
path: root/core/context.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2024-01-03 14:12:28 -0800
committerChris Robinson <[email protected]>2024-01-03 14:12:28 -0800
commited98cbefd014a5166ec086fd276eb283cdab22aa (patch)
tree321f7efe504a010572c15277114883cc72cced34 /core/context.cpp
parentf8604758bc7cc43efa52a305a578ee9cf474f0d6 (diff)
Allocate context property updates in clusters
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);
+}