15template <
class MutexType>
37 mMutexStorage =
new MutexStorage[inNumMutexes];
38 mNumMutexes = inNumMutexes;
51 return hasher(inObjectIndex) & (mNumMutexes - 1);
63 return mMutexStorage[inMutexIndex].mMutex;
71 MutexStorage *end = mMutexStorage + mNumMutexes;
72 for (MutexStorage *m = mMutexStorage; m < end; ++m)
81 MutexStorage *end = mMutexStorage + mNumMutexes;
82 for (MutexStorage *m = mMutexStorage; m < end; ++m)
88 struct alignas(JPH_CACHE_LINE_SIZE) MutexStorage
95 MutexStorage * mMutexStorage =
nullptr;
unsigned int uint
Definition Core.h:564
#define JPH_NAMESPACE_END
Definition Core.h:487
std::uint32_t uint32
Definition Core.h:567
#define JPH_NAMESPACE_BEGIN
Definition Core.h:481
#define JPH_ASSERT(...)
Definition IssueReporting.h:28
constexpr bool IsPowerOf2(T inV)
Check if inV is a power of 2.
Definition Math.h:161
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:51
#define JPH_PROFILE_FUNCTION()
Scope profiling for function.
Definition Profiler.h:270
MutexArray(uint inNumMutexes)
Constructor, constructs an array with inNumMutexes entries.
Definition MutexArray.h:25
uint32 GetMutexIndex(uint32 inObjectIndex) const
Convert an object index to a mutex index.
Definition MutexArray.h:48
~MutexArray()
Destructor.
Definition MutexArray.h:28
JPH_OVERRIDE_NEW_DELETE MutexArray()=default
Constructor, constructs an empty mutex array that you need to initialize with Init().
MutexType & GetMutexByObjectIndex(uint32 inObjectIndex)
Get the mutex belonging to a certain object by index.
Definition MutexArray.h:55
void UnlockAll()
Unlock all mutexes.
Definition MutexArray.h:77
void LockAll()
Lock all mutexes.
Definition MutexArray.h:67
void Init(uint inNumMutexes)
Definition MutexArray.h:32
MutexType & GetMutexByIndex(uint32 inMutexIndex)
Get a mutex by index in the array.
Definition MutexArray.h:61
uint GetNumMutexes() const
Get the number of mutexes that were allocated.
Definition MutexArray.h:42
Fallback hash function that calls T::GetHash().
Definition HashCombine.h:59