diff options
Diffstat (limited to 'src/OSSupport')
-rw-r--r-- | src/OSSupport/Semaphore.cpp | 50 | ||||
-rw-r--r-- | src/OSSupport/Sleep.cpp | 2 | ||||
-rw-r--r-- | src/OSSupport/Thread.cpp | 2 |
3 files changed, 35 insertions, 19 deletions
diff --git a/src/OSSupport/Semaphore.cpp b/src/OSSupport/Semaphore.cpp index 60e5564e4..d919c4744 100644 --- a/src/OSSupport/Semaphore.cpp +++ b/src/OSSupport/Semaphore.cpp @@ -44,48 +44,64 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* #endif } + + + + cSemaphore::~cSemaphore() { #ifdef _WIN32 CloseHandle( m_Handle ); #else - if( m_bNamed ) - { - if( sem_close( (sem_t*)m_Handle ) != 0 ) - { - LOG("ERROR: Could not close cSemaphore. (%i)", errno); - } - } - else - { - sem_destroy( (sem_t*)m_Handle ); - delete (sem_t*)m_Handle; - } + if( m_bNamed ) + { + if( sem_close( (sem_t*)m_Handle ) != 0 ) + { + LOG("ERROR: Could not close cSemaphore. (%i)", errno); + } + } + else + { + sem_destroy( (sem_t*)m_Handle ); + delete (sem_t*)m_Handle; + } m_Handle = 0; #endif } + + + + void cSemaphore::Wait() { #ifndef _WIN32 - if( sem_wait( (sem_t*)m_Handle ) != 0) - { - LOG("ERROR: Could not wait for cSemaphore. (%i)", errno); - } + if( sem_wait( (sem_t*)m_Handle ) != 0) + { + LOG("ERROR: Could not wait for cSemaphore. (%i)", errno); + } #else WaitForSingleObject( m_Handle, INFINITE); #endif } + + + + void cSemaphore::Signal() { #ifndef _WIN32 if( sem_post( (sem_t*)m_Handle ) != 0 ) { - LOG("ERROR: Could not signal cSemaphore. (%i)", errno); + LOG("ERROR: Could not signal cSemaphore. (%i)", errno); } #else ReleaseSemaphore( m_Handle, 1, NULL ); #endif } + + + + diff --git a/src/OSSupport/Sleep.cpp b/src/OSSupport/Sleep.cpp index b18d918fa..223a8b855 100644 --- a/src/OSSupport/Sleep.cpp +++ b/src/OSSupport/Sleep.cpp @@ -14,6 +14,6 @@ void cSleep::MilliSleep( unsigned int a_MilliSeconds ) #ifdef _WIN32 Sleep(a_MilliSeconds); // Don't tick too much #else - usleep(a_MilliSeconds*1000); + usleep(a_MilliSeconds*1000); #endif } diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp index 674e37757..084e0810e 100644 --- a/src/OSSupport/Thread.cpp +++ b/src/OSSupport/Thread.cpp @@ -91,7 +91,7 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) LOGERROR("ERROR: Could not create thread!"); #else DWORD ThreadID = 0; - HANDLE hThread = CreateThread( 0 // security + HANDLE hThread = CreateThread(NULL // security ,0 // stack size , (LPTHREAD_START_ROUTINE) MyThread // function name ,this // parameters |