-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelapsedTimeThread.cpp
More file actions
39 lines (36 loc) · 908 Bytes
/
Copy pathelapsedTimeThread.cpp
File metadata and controls
39 lines (36 loc) · 908 Bytes
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
#include "elapsedTimeThread.h"
#include "utils.h"
void elapsedTimeThread::start(void) {
while(halt==false) {
// lock variable elapsedTimeThread to avoid
// conflicts with programWheel - programWheel
// object should be able to set the elapsedTimeThread to
// zero in order to start this timer when the incubator
// program reaches the next step.
m.lock();
elapsedSeconds+=1;
m.unlock();
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
void elapsedTimeThread::stop(void) {
m.lock();
halt = true;
m.unlock();
}
void elapsedTimeThread::operator()() {
while(halt==false) {
elapsedSeconds++;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
double elapsedTimeThread::getElapsedSeconds(void) {
return elapsedSeconds;
}
elapsedTimeThread::elapsedTimeThread(void) {
elapsedSeconds = 0.0;
halt = false;
}
elapsedTimeThread::~elapsedTimeThread(void) {
;
}