-
Notifications
You must be signed in to change notification settings - Fork 0
/
Philosopher.h
36 lines (33 loc) · 918 Bytes
/
Philosopher.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
#ifndef PHILOSOPHER_H
#define PHILOSOPHER_H
#include "Fork.h"
class Philosopher
{
public:
Philosopher(int _id, Fork* leftFork,
Fork* rightFork);
Philosopher(int _id, Fork* leftFork);
virtual ~Philosopher();
bool isDoneEating();
void setLeftNeighbour(Philosopher* left);
void setRightNeighbour(Philosopher* right);
int sayYourNameBitch();
void acquireForks();
void iAmEating();
bool hasBothForks();
void lockForks();
//void releaseForks();
protected:
Fork* giveLeftFork();
Fork* giveRightFork();
void takeLeftFork();
void takeRightFork();
private:
int _id;
bool full;
Fork* leftFork;
Fork* rightFork;
Philosopher* leftNeighbour;
Philosopher* rightNeighbour;
};
#endif // PHILOSOPHER_H