forked from 1emu/ProductorConsumidorNM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SemaphoreArray.h
44 lines (36 loc) · 1.1 KB
/
SemaphoreArray.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* SemaphoreArray.h
*
* Created on: May 8, 2014
* Author: jp
*/
#ifndef SEMAPHOREARRAY_H_
#define SEMAPHOREARRAY_H_
#ifndef PERMISSIONS
#define PERMISSIONS 0660
#endif
#include "Includes.h"
class SemaphoreArray {
public:
SemaphoreArray();
virtual ~SemaphoreArray();
static SemaphoreArray* create(unsigned int id,unsigned int size, unsigned int* initStatus);
static SemaphoreArray* get(unsigned int id, unsigned int size);
/* We redefine create, get and destroy for a mutex */
static SemaphoreArray* create(unsigned int id);
static SemaphoreArray* get(unsigned int id);
static void destroy(unsigned int id);
/* Defaults are for mutex */
void wait(unsigned int index = 0);
void post(unsigned int index = 0);
static void destroy(unsigned int id, unsigned int size);
private:
int semaphoreArrayId;
int id;
void setSemaphoreArrayId(int id);
void setId(int id);
void init(unsigned int size, unsigned int* initStatus);
static unsigned int getSemaphoreArrayId(unsigned int id, unsigned int size);
static void notifyError(int id, std::string failingMethod);
};
#endif /* SEMAPHOREARRAY_H_ */