-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paththreadedclass.h
42 lines (33 loc) · 903 Bytes
/
threadedclass.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
37
38
39
40
41
42
/*
Copyright 2016 Navtech Radar Limited
This file is part of iasdk which is released under The MIT License (MIT).
See file LICENSE.txt in project root or go to https://opensource.org/licenses/MIT
for full license details.
*/
#pragma once
#include "common.h"
#include <thread>
#include <atomic>
#include <memory>
namespace Navtech
{
class ThreadedClass
{
public:
explicit ThreadedClass() = default;
virtual ~ThreadedClass() {}
ThreadedClass(const ThreadedClass&) = delete;
ThreadedClass& operator= (const ThreadedClass&) = delete;
virtual void Start();
virtual void Stop(const bool finishWork = false);
virtual void Join(void);
protected:
virtual void DoWork() = 0;
virtual void PreStop(const bool finishWork = false);
virtual void PostStart();
std::shared_ptr<std::thread> _thread = nullptr;
std::atomic<bool> _stopRequested;
private:
void ThreadMethod();
};
}