-
Notifications
You must be signed in to change notification settings - Fork 1
/
Philo.hpp
45 lines (39 loc) · 951 Bytes
/
Philo.hpp
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
45
//
// Philo.hpp
// thread-filosofi
//
// Created by Francesco Argentieri on 07/08/16.
// Copyright © 2016 Francesco Argentieri. All rights reserved.
//
#ifndef PHILOSOPHER_HPP
#define PHILOSOPHER_HPP
#include "fork.hpp"
enum class action {THINK, EAT, SLEEP};
class Philosopher
{
public:
Philosopher();
~Philosopher() {}
//Philosopher activity
void thinking();
void eating();
void sleeping();
action GetPhilosopherState();
unsigned int getEat();
unsigned int getSleep();
unsigned int getThink();
void setCanEat(Fork *forkSX, Fork *forkDX);
bool getCanEat();
//fork interaction
void SetLeftFork(Fork *fork);
void SetRightFork(Fork *fork);
void ReleaseLeftFork(Fork *fork);
void ReleaseRightFork(Fork *fork);
private:
unsigned int m_num_eat;
unsigned int m_num_sleep;
unsigned int m_num_think;
bool m_allFork;
action m_state;
};
#endif // PHILOSOPHER_HPP