-
Notifications
You must be signed in to change notification settings - Fork 5
/
Thread.hpp
55 lines (36 loc) · 904 Bytes
/
Thread.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
#ifndef ___INANITY_THREAD_HPP___
#define ___INANITY_THREAD_HPP___
#include "Handler.hpp"
#if defined(___INANITY_PLATFORM_WINDOWS)
#include "platform/Win32Handle.hpp"
#include "platform/windows.hpp"
#elif defined(___INANITY_PLATFORM_POSIX)
#include <sys/types.h>
#else
#error Unknown platform
#endif
BEGIN_INANITY
/// Класс потока выполнения.
class Thread : public Object
{
public:
typedef DataHandler<ptr<Thread> > ThreadHandler;
private:
ptr<ThreadHandler> handler;
#if defined(___INANITY_PLATFORM_WINDOWS)
Platform::Win32Handle thread;
static DWORD CALLBACK ThreadRoutine(void* self);
#elif defined(___INANITY_PLATFORM_POSIX)
pthread_t thread;
static void* ThreadRoutine(void* self);
#else
#error Unknown platform
#endif
void Run();
public:
Thread(ptr<ThreadHandler> handler);
void WaitEnd();
static void Sleep(int milliseconds);
};
END_INANITY
#endif