-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndicator.hpp
77 lines (61 loc) · 1.17 KB
/
Indicator.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Indicator.hpp
*
* Created on: 04.04.2017
* Author: hartung
*/
#ifndef INDICATOR_HPP_
#define INDICATOR_HPP_
class Indicator
{
unsigned status;
unsigned count;
public:
bool isFree() const
{
return count == 0;
}
void clear()
{
status = 0;
count = 0;
}
void setFree()
{
count = 0;
}
unsigned getCount() const
{
return count;
}
void setCount(const unsigned & in)
{
count = in;
}
bool shouldFinish() const
{
return status >= 2;
}
bool shouldAddThread() const
{
return status == 1;
}
void setAddThread()
{
status = 1;
}
// only call when shouldFinish is true
unsigned getNumComms()
{
return status-2;
}
void setFinished(const unsigned & in)
{
status = in + 2;
}
void setOnlyElements()
{
status = 0;
}
};
#endif /* INDICATOR_HPP_ */