// Port of pflib/external/openal/CAMutex.h (Apple Core Audio utility class, Playground SDK 4.0): CAMutex, a pthread // mutex that remembers its owning thread, so Lock / Try on the owning thread return without touching the pthread // mutex. CAMutex.cpp is ported next to this file. Layout from the DWARF of parity-out/sdk/dbgobj/CAMutex.o // (size 56): +0x00 vtable, +0x04 mName, +0x08 mOwner, +0x0c mMutex. // // The SDK header's nested Locker helper class is not carried (no ported code uses it). Callers lock with // `bool wasLocked = guard.Lock();` and unlock only when that returned true (DWARF local "wasLocked"). #ifndef CAMUTEX_H_INCLUDED #define CAMUTEX_H_INCLUDED #include class CAMutex { public: CAMutex(const char* inName); virtual ~CAMutex(); virtual bool Lock(); virtual void Unlock(); virtual bool Try(bool& outWasLocked); virtual bool IsFree() const; virtual bool IsOwnedByCurrentThread() const; protected: const char* mName; pthread_t mOwner; pthread_mutex_t mMutex; }; #endif