Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
MutexArray< MutexType > Class Template Reference

#include <MutexArray.h>

Inheritance diagram for MutexArray< MutexType >:
NonCopyable

Public Member Functions

 MutexArray ()=default
 Constructor, constructs an empty mutex array that you need to initialize with Init() More...
 
 MutexArray (uint inNumMutexes)
 Constructor, constructs an array with inNumMutexes entries. More...
 
 ~MutexArray ()
 Destructor. More...
 
void Init (uint inNumMutexes)
 
uint GetNumMutexes () const
 Get the number of mutexes that were allocated. More...
 
uint32 GetMutexIndex (uint32 inObjectIndex) const
 Convert an object index to a mutex index. More...
 
MutexType & GetMutexByObjectIndex (uint32 inObjectIndex)
 Get the mutex belonging to a certain object by index. More...
 
MutexType & GetMutexByIndex (uint32 inMutexIndex)
 Get a mutex by index in the array. More...
 
void LockAll ()
 Lock all mutexes. More...
 
void UnlockAll ()
 Unlock all mutexes. More...
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Detailed Description

template<class MutexType>
class MutexArray< MutexType >

A mutex array protects a number of resources with a limited amount of mutexes. It uses hashing to find the mutex of a particular object. The idea is that if the amount of threads is much smaller than the amount of mutexes that there is a relatively small chance that two different objects map to the same mutex.

Constructor & Destructor Documentation

◆ MutexArray() [1/2]

template<class MutexType >
MutexArray< MutexType >::MutexArray ( )
default

Constructor, constructs an empty mutex array that you need to initialize with Init()

◆ MutexArray() [2/2]

template<class MutexType >
MutexArray< MutexType >::MutexArray ( uint  inNumMutexes)
inlineexplicit

Constructor, constructs an array with inNumMutexes entries.

◆ ~MutexArray()

template<class MutexType >
MutexArray< MutexType >::~MutexArray ( )
inline

Destructor.

Member Function Documentation

◆ GetMutexByIndex()

template<class MutexType >
MutexType & MutexArray< MutexType >::GetMutexByIndex ( uint32  inMutexIndex)
inline

Get a mutex by index in the array.

◆ GetMutexByObjectIndex()

template<class MutexType >
MutexType & MutexArray< MutexType >::GetMutexByObjectIndex ( uint32  inObjectIndex)
inline

Get the mutex belonging to a certain object by index.

◆ GetMutexIndex()

template<class MutexType >
uint32 MutexArray< MutexType >::GetMutexIndex ( uint32  inObjectIndex) const
inline

Convert an object index to a mutex index.

◆ GetNumMutexes()

template<class MutexType >
uint MutexArray< MutexType >::GetNumMutexes ( ) const
inline

Get the number of mutexes that were allocated.

◆ Init()

template<class MutexType >
void MutexArray< MutexType >::Init ( uint  inNumMutexes)
inline

Initialization

Parameters
inNumMutexesThe amount of mutexes to allocate

◆ LockAll()

template<class MutexType >
void MutexArray< MutexType >::LockAll ( )
inline

Lock all mutexes.

◆ UnlockAll()

template<class MutexType >
void MutexArray< MutexType >::UnlockAll ( )
inline

Unlock all mutexes.


The documentation for this class was generated from the following file: