aboutsummaryrefslogtreecommitdiff
path: root/zencore/iobuffer.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-04-28 22:18:40 +0200
committerDan Engelbrecht <[email protected]>2022-04-28 22:18:40 +0200
commite2b0687d589b6bd20baaba84ec44841f21c66161 (patch)
tree34c18bcc92a87ddb09e0f1d9fbf3f055d6fc3229 /zencore/iobuffer.cpp
parentMerge remote-tracking branch 'origin/main' into de/cache-with-block-store (diff)
parentMerge pull request #83 from EpicGames/de/minor-optimizations (diff)
downloadzen-e2b0687d589b6bd20baaba84ec44841f21c66161.tar.xz
zen-e2b0687d589b6bd20baaba84ec44841f21c66161.zip
Merge remote-tracking branch 'origin/main' into de/cache-with-block-store
Diffstat (limited to 'zencore/iobuffer.cpp')
-rw-r--r--zencore/iobuffer.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/zencore/iobuffer.cpp b/zencore/iobuffer.cpp
index 8a3ab8427..c069aa0f1 100644
--- a/zencore/iobuffer.cpp
+++ b/zencore/iobuffer.cpp
@@ -226,7 +226,15 @@ IoBufferExtendedCore::~IoBufferExtendedCore()
m_DataPtr = nullptr;
}
-static RwLock g_MappingLock;
+static RwLock g_MappingLock[0x40];
+
+static RwLock&
+MappingLockForInstance(const IoBufferExtendedCore* instance)
+{
+ intptr_t base = (intptr_t)instance;
+ size_t lock_index = ((base >> 8) ^ (base >> 16)) & 0x3f;
+ return g_MappingLock[lock_index];
+}
void
IoBufferExtendedCore::Materialize() const
@@ -237,7 +245,7 @@ IoBufferExtendedCore::Materialize() const
if (m_Flags.load(std::memory_order_acquire) & kIsMaterialized)
return;
- RwLock::ExclusiveLockScope _(g_MappingLock);
+ RwLock::ExclusiveLockScope _(MappingLockForInstance(this));
// Someone could have gotten here first
// We can use memory_order_relaxed on this load because the mutex has already provided the fence