diff options
| author | Dan Engelbrecht <[email protected]> | 2022-04-29 17:21:37 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-04-29 17:21:37 +0200 |
| commit | 32baec4f0790da712a3d3a7892e401cf6e0cc5eb (patch) | |
| tree | cbac77f661f73709de55d7a14deaca1171967477 /zencore | |
| parent | Merge remote-tracking branch 'origin/main' into de/cache-with-block-store (diff) | |
| parent | Merge pull request #84 from EpicGames/de/cleanup-lock-sharding-in-iobuffer (diff) | |
| download | zen-32baec4f0790da712a3d3a7892e401cf6e0cc5eb.tar.xz zen-32baec4f0790da712a3d3a7892e401cf6e0cc5eb.zip | |
Merge remote-tracking branch 'origin/main' into de/cache-with-block-store
Diffstat (limited to 'zencore')
| -rw-r--r-- | zencore/iobuffer.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/zencore/iobuffer.cpp b/zencore/iobuffer.cpp index c069aa0f1..46b9ab336 100644 --- a/zencore/iobuffer.cpp +++ b/zencore/iobuffer.cpp @@ -226,14 +226,17 @@ IoBufferExtendedCore::~IoBufferExtendedCore() m_DataPtr = nullptr; } -static RwLock g_MappingLock[0x40]; +static constexpr size_t MappingLockCount = 64; +static_assert(IsPow2(MappingLockCount), "MappingLockCount must be power of two"); + +static RwLock g_MappingLocks[MappingLockCount]; 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]; + size_t lock_index = ((base >> 8) ^ (base >> 16)) & (MappingLockCount - 1u); + return g_MappingLocks[lock_index]; } void |