blob: d0ac6deb43c3da2760cbd72887df66b54390c26d (
plain)
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
56
57
58
59
60
61
62
63
|
#ifndef MTHREAD_H
#define MTHREAD_H
#include "Base.h"
#ifndef WIN32
#include <pthread.h>
#else
#include <windows.h>
//#include "Process.h"
#define WIN32_THREAD_STACK_SIZE 0x10000
#endif
enum ThreadPriority
{
IDLE,
LOWER,
LOW,
NORMAL,
HIGH,
HIGHER,
REALTIME
};
class MThread: public Base
{
public:
static MThread *Start (void (*routine) (void *arg), void *arg);
MThread ();
~MThread ();
bool SetPriority (ThreadPriority prio);
void (*routine) (void *arg);
void *arg;
#ifdef WIN32
HANDLE th;
ULONG id;
#else
pthread_t tid;
#endif
};
class MMutex : public Base
{
public:
#ifdef WIN32
HANDLE sem;
#else
pthread_mutex_t mutex;
static pthread_mutexattr_t attr;
static int attr_refcount;
#endif
static MMutex *Create ();
MMutex ();
virtual ~MMutex ();
virtual bool Lock ();
virtual bool TryLock ();
virtual void Unlock ();
};
#endif // MTHREAD_H
|