-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreading.h
More file actions
52 lines (38 loc) · 830 Bytes
/
threading.h
File metadata and controls
52 lines (38 loc) · 830 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
43
44
45
46
47
48
49
50
51
52
#ifndef THREADING_H
#define THREADING_H
#include <windows.h>
#include <process.h>
#include <memory>
#include <cassert>
#include <QErrorMessage>
#include <QString>
class Runnable
{
public:
virtual void* run() = 0;
virtual ~Runnable();
};
class Thread
{
private:
HANDLE threadHandle;
unsigned threadId;
std::unique_ptr<Runnable> runnable;
Thread(const Thread&);
const Thread& operator=(const Thread&);
void setCompleted();
void* result;
void* run();
static unsigned WINAPI startThreadRunnable(LPVOID pVoid);
static unsigned WINAPI startThread(LPVOID pVoid);
public:
Thread(Runnable* run);
Thread();
~Thread();
void start();
void suspend();
void terminate();
void* join();
void printError(const QString& message);
};
#endif // THREADING_H