You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
409 B
22 lines
409 B
#ifndef _SEMAPHORE_H_ |
|
#define _SEMAPHORE_H_ |
|
|
|
#include <semaphore.h> |
|
|
|
class Semaphore { |
|
public: |
|
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); } |
|
|
|
protected: |
|
Semaphore(const Semaphore& s); |
|
Semaphore& operator=(const Semaphore& s); |
|
|
|
private: |
|
sem_t s; |
|
}; |
|
|
|
#endif //_SEMAPHORE_H_
|
|
|