#ifndef FWCountedSemaphore_h
#define FWCountedSemaphore_h
//#pragma warning( disable : 4290 )
#include <string>
#include "FWOS.h"
#include "FWCoreDLLImportExportDeclaration.h"
/*#ifdef FW_OS_WINDOWS
#include "Win\semaphore.h"
#else
#include "Posix\semaphore.h"
#endif*/
#include "PosixThreadInclude\semaphore.h"
namespace CoreFW
{
class CORE_DLL_DECLARATION_SPECIFIER FWCountedSemaphore
{
private:
mutable sem_t m_CountedSemaphore ;
void operator=( FWCountedSemaphore &CountedSemaphoreObject ) {}
FWCountedSemaphore( const FWCountedSemaphore &CountedSemaphoreObject ) {}
public:
//FWCountedSemaphore() throw( std::string )
FWCountedSemaphore()
{
int res = sem_init( &m_CountedSemaphore, 0, 0 ) ;
if( res != 0 )
throw( std::string( "Semaphore Initialization Failed" ) ) ;
}
virtual ~FWCountedSemaphore()
{
sem_destroy( &m_CountedSemaphore ) ;
}
int Wait() const
{
sem_wait( &m_CountedSemaphore ) ;
return 0 ;
}
int Post() const
{
sem_post( &m_CountedSemaphore ) ;
return 0 ;
}
} ;
} // End namespace
#endif // FWCountedSemaphore_h