Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files. make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type. This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
@@ -82,65 +82,67 @@
|
||||
#define VHACD_VERIFY(x) assert((x))
|
||||
#endif
|
||||
|
||||
namespace VHACD {
|
||||
class Mutex {
|
||||
namespace VHACD
|
||||
{
|
||||
class Mutex
|
||||
{
|
||||
public:
|
||||
Mutex(void)
|
||||
{
|
||||
Mutex(void)
|
||||
{
|
||||
#if defined(WIN32) || defined(_XBOX)
|
||||
InitializeCriticalSection(&m_mutex);
|
||||
InitializeCriticalSection(&m_mutex);
|
||||
#elif defined(__APPLE__) || defined(__linux__)
|
||||
pthread_mutexattr_t mutexAttr; // Mutex Attribute
|
||||
VHACD_VERIFY(pthread_mutexattr_init(&mutexAttr) == 0);
|
||||
VHACD_VERIFY(pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_RECURSIVE_NP) == 0);
|
||||
VHACD_VERIFY(pthread_mutex_init(&m_mutex, &mutexAttr) == 0);
|
||||
VHACD_VERIFY(pthread_mutexattr_destroy(&mutexAttr) == 0);
|
||||
pthread_mutexattr_t mutexAttr; // Mutex Attribute
|
||||
VHACD_VERIFY(pthread_mutexattr_init(&mutexAttr) == 0);
|
||||
VHACD_VERIFY(pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_RECURSIVE_NP) == 0);
|
||||
VHACD_VERIFY(pthread_mutex_init(&m_mutex, &mutexAttr) == 0);
|
||||
VHACD_VERIFY(pthread_mutexattr_destroy(&mutexAttr) == 0);
|
||||
#endif
|
||||
}
|
||||
~Mutex(void)
|
||||
{
|
||||
}
|
||||
~Mutex(void)
|
||||
{
|
||||
#if defined(WIN32) || defined(_XBOX)
|
||||
DeleteCriticalSection(&m_mutex);
|
||||
DeleteCriticalSection(&m_mutex);
|
||||
#elif defined(__APPLE__) || defined(__linux__)
|
||||
VHACD_VERIFY(pthread_mutex_destroy(&m_mutex) == 0);
|
||||
VHACD_VERIFY(pthread_mutex_destroy(&m_mutex) == 0);
|
||||
#endif
|
||||
}
|
||||
void Lock(void)
|
||||
{
|
||||
}
|
||||
void Lock(void)
|
||||
{
|
||||
#if defined(WIN32) || defined(_XBOX)
|
||||
EnterCriticalSection(&m_mutex);
|
||||
EnterCriticalSection(&m_mutex);
|
||||
#elif defined(__APPLE__) || defined(__linux__)
|
||||
VHACD_VERIFY(pthread_mutex_lock(&m_mutex) == 0);
|
||||
VHACD_VERIFY(pthread_mutex_lock(&m_mutex) == 0);
|
||||
#endif
|
||||
}
|
||||
bool TryLock(void)
|
||||
{
|
||||
}
|
||||
bool TryLock(void)
|
||||
{
|
||||
#if defined(WIN32) || defined(_XBOX)
|
||||
bool bRet = false;
|
||||
//assert(("TryEnterCriticalSection seems to not work on XP???", 0));
|
||||
bRet = TryEnterCriticalSection(&m_mutex) ? true : false;
|
||||
return bRet;
|
||||
bool bRet = false;
|
||||
//assert(("TryEnterCriticalSection seems to not work on XP???", 0));
|
||||
bRet = TryEnterCriticalSection(&m_mutex) ? true : false;
|
||||
return bRet;
|
||||
#elif defined(__APPLE__) || defined(__linux__)
|
||||
int result = pthread_mutex_trylock(&m_mutex);
|
||||
return (result == 0);
|
||||
int result = pthread_mutex_trylock(&m_mutex);
|
||||
return (result == 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void Unlock(void)
|
||||
{
|
||||
void Unlock(void)
|
||||
{
|
||||
#if defined(WIN32) || defined(_XBOX)
|
||||
LeaveCriticalSection(&m_mutex);
|
||||
LeaveCriticalSection(&m_mutex);
|
||||
#elif defined(__APPLE__) || defined(__linux__)
|
||||
VHACD_VERIFY(pthread_mutex_unlock(&m_mutex) == 0);
|
||||
VHACD_VERIFY(pthread_mutex_unlock(&m_mutex) == 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
#if defined(WIN32) || defined(_XBOX)
|
||||
CRITICAL_SECTION m_mutex;
|
||||
CRITICAL_SECTION m_mutex;
|
||||
#elif defined(__APPLE__) || defined(__linux__)
|
||||
pthread_mutex_t m_mutex;
|
||||
pthread_mutex_t m_mutex;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
#endif // VHACD_MUTEX_H
|
||||
} // namespace VHACD
|
||||
#endif // VHACD_MUTEX_H
|
||||
|
||||
Reference in New Issue
Block a user