1
0

Fixed tabs used for alignment.

This commit is contained in:
madmaxoft
2014-07-17 23:15:53 +02:00
parent d0cc9aedb3
commit c03161f75d
29 changed files with 115 additions and 99 deletions

View File

@@ -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
}