Added sharedSynchronization library

This commit is contained in:
Anonymous
2014-01-14 00:45:55 -07:00
parent 1f331006e1
commit 9cbb2cfecb
47 changed files with 1439 additions and 0 deletions
@@ -0,0 +1,40 @@
// ======================================================================
//
// Semaphore.cpp
// Acy Stapp
//
// Copyright 6/19/2001 Sony Online Entertainment
//
// ======================================================================
#include "sharedFoundation/FirstSharedFoundation.h"
#include "sharedSynchronization/Semaphore.h"
Semaphore::Semaphore(int count, int initial)
{
sem_init(&sem, false, initial);
}
Semaphore::~Semaphore()
{
sem_destroy(&sem);
}
void Semaphore::wait()
{
sem_wait(&sem);
}
void Semaphore::wait(unsigned int maxDurationMs)
{
timespec ts;
ts.tv_sec = maxDurationMs/1000000;
ts.tv_nsec = maxDurationMs%1000000;
sem_timedwait(&sem, &ts);
}
void Semaphore::signal(int count)
{
sem_post(&sem);
}