2006-02-02 16:55:44 +01:00
|
|
|
#ifndef _SEMAPHORE_H_
|
|
|
|
#define _SEMAPHORE_H_
|
|
|
|
|
|
|
|
#include <semaphore.h>
|
|
|
|
|
|
|
|
class Semaphore {
|
|
|
|
public:
|
2006-02-19 18:45:56 +01:00
|
|
|
Semaphore() { sem_init(&s, 0, 0); }
|
|
|
|
Semaphore(int i) { sem_init(&s, 0, i); }
|
|
|
|
~Semaphore() { sem_destroy(&s); }
|
|
|
|
void wait() { sem_wait(&s); }
|
|
|
|
void post() { sem_post(&s); }
|
2006-03-05 02:28:19 +01:00
|
|
|
|
2006-02-02 16:55:44 +01:00
|
|
|
protected:
|
|
|
|
Semaphore(const Semaphore& s);
|
|
|
|
Semaphore& operator=(const Semaphore& s);
|
|
|
|
|
|
|
|
private:
|
|
|
|
sem_t s;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //_SEMAPHORE_H_
|