|
@@ -29,9 +29,9 @@ struct Semaphore
|
|
|
#endif
|
|
#endif
|
|
|
{
|
|
{
|
|
|
#if CROWN_PLATFORM_POSIX
|
|
#if CROWN_PLATFORM_POSIX
|
|
|
- int result = pthread_cond_init(&m_cond, NULL);
|
|
|
|
|
- CE_ASSERT(result == 0, "pthread_cond_init: errno = %d", result);
|
|
|
|
|
- CE_UNUSED(result);
|
|
|
|
|
|
|
+ int err = pthread_cond_init(&_cond, NULL);
|
|
|
|
|
+ CE_ASSERT(err == 0, "pthread_cond_init: errno = %d", err);
|
|
|
|
|
+ CE_UNUSED(err);
|
|
|
#elif CROWN_PLATFORM_WINDOWS
|
|
#elif CROWN_PLATFORM_WINDOWS
|
|
|
_handle = CreateSemaphore(NULL, 0, LONG_MAX, NULL);
|
|
_handle = CreateSemaphore(NULL, 0, LONG_MAX, NULL);
|
|
|
CE_ASSERT(_handle != NULL, "CreateSemaphore: GetLastError = %d", GetLastError());
|
|
CE_ASSERT(_handle != NULL, "CreateSemaphore: GetLastError = %d", GetLastError());
|
|
@@ -42,9 +42,9 @@ struct Semaphore
|
|
|
~Semaphore()
|
|
~Semaphore()
|
|
|
{
|
|
{
|
|
|
#if CROWN_PLATFORM_POSIX
|
|
#if CROWN_PLATFORM_POSIX
|
|
|
- int result = pthread_cond_destroy(&m_cond);
|
|
|
|
|
- CE_ASSERT(result == 0, "pthread_cond_destroy: errno = %d", result);
|
|
|
|
|
- CE_UNUSED(result);
|
|
|
|
|
|
|
+ int err = pthread_cond_destroy(&_cond);
|
|
|
|
|
+ CE_ASSERT(err == 0, "pthread_cond_destroy: errno = %d", err);
|
|
|
|
|
+ CE_UNUSED(err);
|
|
|
#elif CROWN_PLATFORM_WINDOWS
|
|
#elif CROWN_PLATFORM_WINDOWS
|
|
|
BOOL err = CloseHandle(_handle);
|
|
BOOL err = CloseHandle(_handle);
|
|
|
CE_ASSERT(err != 0, "CloseHandle: GetLastError = %d", GetLastError());
|
|
CE_ASSERT(err != 0, "CloseHandle: GetLastError = %d", GetLastError());
|
|
@@ -59,9 +59,9 @@ struct Semaphore
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < count; ++i)
|
|
for (uint32_t i = 0; i < count; ++i)
|
|
|
{
|
|
{
|
|
|
- int result = pthread_cond_signal(&m_cond);
|
|
|
|
|
- CE_ASSERT(result == 0, "pthread_cond_signal: errno = %d", result);
|
|
|
|
|
- CE_UNUSED(result);
|
|
|
|
|
|
|
+ int err = pthread_cond_signal(&_cond);
|
|
|
|
|
+ CE_ASSERT(err == 0, "pthread_cond_signal: errno = %d", err);
|
|
|
|
|
+ CE_UNUSED(err);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
_count += count;
|
|
_count += count;
|
|
@@ -79,16 +79,16 @@ struct Semaphore
|
|
|
|
|
|
|
|
while (_count <= 0)
|
|
while (_count <= 0)
|
|
|
{
|
|
{
|
|
|
- int result = pthread_cond_wait(&m_cond, &(_mutex._mutex));
|
|
|
|
|
- CE_ASSERT(result == 0, "pthread_cond_wait: errno = %d", result);
|
|
|
|
|
- CE_UNUSED(result);
|
|
|
|
|
|
|
+ int err = pthread_cond_wait(&_cond, &(_mutex._mutex));
|
|
|
|
|
+ CE_ASSERT(err == 0, "pthread_cond_wait: errno = %d", err);
|
|
|
|
|
+ CE_UNUSED(err);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
_count--;
|
|
_count--;
|
|
|
#elif CROWN_PLATFORM_WINDOWS
|
|
#elif CROWN_PLATFORM_WINDOWS
|
|
|
- DWORD result = WaitForSingleObject(_handle, INFINITE);
|
|
|
|
|
- CE_ASSERT(result == WAIT_OBJECT_0, "WaitForSingleObject: GetLastError = %d", GetLastError());
|
|
|
|
|
- CE_UNUSED(result);
|
|
|
|
|
|
|
+ DWORD err = WaitForSingleObject(_handle, INFINITE);
|
|
|
|
|
+ CE_ASSERT(err == WAIT_OBJECT_0, "WaitForSingleObject: GetLastError = %d", GetLastError());
|
|
|
|
|
+ CE_UNUSED(err);
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -96,7 +96,7 @@ private:
|
|
|
|
|
|
|
|
#if CROWN_PLATFORM_POSIX
|
|
#if CROWN_PLATFORM_POSIX
|
|
|
Mutex _mutex;
|
|
Mutex _mutex;
|
|
|
- pthread_cond_t m_cond;
|
|
|
|
|
|
|
+ pthread_cond_t _cond;
|
|
|
int32_t _count;
|
|
int32_t _count;
|
|
|
#elif CROWN_PLATFORM_WINDOWS
|
|
#elif CROWN_PLATFORM_WINDOWS
|
|
|
HANDLE _handle;
|
|
HANDLE _handle;
|