12template <
bool Write,
class BodyType>
21 mBodyLockInterface(inBodyLockInterface),
22 mMutexMask(inBodyLockInterface.GetMutexMask(inBodyIDs, inNumber)),
30 inBodyLockInterface.
LockWrite(mMutexMask);
32 inBodyLockInterface.
LockRead(mMutexMask);
65 inline BodyType *
GetBody(
int inBodyIndex)
const
68 JPH_ASSERT(inBodyIndex >= 0 && inBodyIndex < mNumBodyIDs);
71 const BodyID &body_id = mBodyIDs[inBodyIndex];
#define JPH_NAMESPACE_END
Definition: Core.h:419
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:413
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition: BodyID.h:13
bool IsInvalid() const
Check if the ID is valid.
Definition: BodyID.h:65
Base class interface for locking a body. Usually you will use BodyLockRead / BodyLockWrite / BodyLock...
Definition: BodyLockInterface.h:17
virtual void UnlockRead(SharedMutex *inMutex) const =0
Body * TryGetBody(const BodyID &inBodyID) const
Convert body ID to body.
Definition: BodyLockInterface.h:50
BodyManager::MutexMask MutexMask
Redefine MutexMask.
Definition: BodyLockInterface.h:20
virtual void UnlockWrite(SharedMutex *inMutex) const =0
virtual SharedMutex * LockRead(const BodyID &inBodyID) const =0
virtual SharedMutex * LockWrite(const BodyID &inBodyID) const =0
Base class for locking multiple bodies for the duration of the scope of this class (do not use direct...
Definition: BodyLockMulti.h:14
BodyType * GetBody(int inBodyIndex) const
Access the body (returns null if body was not properly locked)
Definition: BodyLockMulti.h:65
~BodyLockMultiBase()
Destructor will unlock the bodies.
Definition: BodyLockMulti.h:53
BodyLockMultiBase(const BodyLockInterface &inBodyLockInterface, const BodyID *inBodyIDs, int inNumber)
Constructor will lock the bodies.
Definition: BodyLockMulti.h:20
int GetNumBodies() const
Returns the number of bodies that were locked.
Definition: BodyLockMulti.h:59
void ReleaseLocks()
Explicitly release the locks on all bodies (normally this is done in the destructor)
Definition: BodyLockMulti.h:37
BodyLockInterface::MutexMask MutexMask
Redefine MutexMask.
Definition: BodyLockMulti.h:17
Definition: BodyLockMulti.h:110
Specialization that locks multiple bodies for writing to.
Definition: BodyLockMulti.h:116
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11