diff options
| author | Dan Engelbrecht <[email protected]> | 2022-04-28 22:18:40 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-04-28 22:18:40 +0200 |
| commit | e2b0687d589b6bd20baaba84ec44841f21c66161 (patch) | |
| tree | 34c18bcc92a87ddb09e0f1d9fbf3f055d6fc3229 /zencore/iobuffer.cpp | |
| parent | Merge remote-tracking branch 'origin/main' into de/cache-with-block-store (diff) | |
| parent | Merge pull request #83 from EpicGames/de/minor-optimizations (diff) | |
| download | zen-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.cpp | 12 |
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 |