21 lines
404 B
C++
21 lines
404 B
C++
#include "PassportSemaphore.hpp"
|
|
|
|
PassportSemaphore::PassportSemaphore(long max, long count)
|
|
{
|
|
mSemaphore = CreateSemaphore(NULL, count, max, NULL);
|
|
}
|
|
|
|
void PassportSemaphore::acquire()
|
|
{
|
|
WaitForSingleObject(mSemaphore, INFINITE);
|
|
}
|
|
|
|
void PassportSemaphore::release()
|
|
{
|
|
ReleaseSemaphore(mSemaphore, 1, NULL);
|
|
}
|
|
|
|
PassportSemaphore::~PassportSemaphore()
|
|
{
|
|
CloseHandle(mSemaphore);
|
|
} |