28 lines
771 B
C++

// Copyright (C) 2003 Intel Corporation
//////////////////////////////////////////////////////////////////////////
// Semaphore.h
//
// This file contains the definition of the Semaphore class
//////////////////////////////////////////////////////////////////////////
#ifndef _LAD_SEMAPHORE_H
#define _LAD_SEMAPHORE_H
class OSSemaphore;
class Semaphore {
public:
Semaphore(int maxval = 1);
Semaphore (const Semaphore& rhs);
~Semaphore();
void acquire(); // blocks until value !=0, and decrements the value
void release(); // increments the value by 1
bool acquireTry(); // try to acquire the semaphore: return 'true' if succeded
Semaphore& operator= (const Semaphore& rhs);
private:
OSSemaphore* _osSemaphore;
};
#endif //_LAD_SEMAPHORE_H