-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkerrs.cpp
More file actions
44 lines (30 loc) · 783 Bytes
/
workerrs.cpp
File metadata and controls
44 lines (30 loc) · 783 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
40
41
42
//This is an open source non-commercial project. Dear PVS-Studio, please check it.
#include "workerrs.h"
Worker::Worker(TypeParams _params, TypeInterface interface):
params(_params)
{
//setup connection interface
setInterface(interface);
auto dev = getInterface()->getDevName();
std::cout << "Worker devPath=" << dev << std::endl;
if(!getInterface()->open())
{
throw WorkerEx("Error open dev=" + dev);
}
isRun = true;
run_thread = make_unique<std::thread>(&Worker::run, this);
}
Worker::~Worker()
{
isRun = false;
run_thread->join();
getInterface()->close();
}
void Worker::run()
{
while(isRun)
{
run_func();
std::this_thread::sleep_for(std::chrono::milliseconds(DELAY_MSEC));
}
}