summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/Semaphore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/OSSupport/Semaphore.cpp')
-rw-r--r--src/OSSupport/Semaphore.cpp50
1 files changed, 33 insertions, 17 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
}
+
+
+
+