root/trunk/src/shared/Mthread.h @ 13

Revision 2, 1.1 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
1#ifndef MTHREAD_H
2#define MTHREAD_H
3
4#include "Base.h"
5#ifndef WIN32
6#include <pthread.h>
7#else
8#include <windows.h>
9//#include "Process.h"
10#define WIN32_THREAD_STACK_SIZE 0x10000
11#endif
12
13enum ThreadPriority
14{
15    IDLE,
16    LOWER,
17    LOW,
18    NORMAL,
19    HIGH,
20    HIGHER,
21    REALTIME
22};
23
24class MThread: public Base
25{
26    public:
27        static MThread *Start (void (*routine) (void *arg), void *arg);
28        MThread ();
29        ~MThread ();
30        bool SetPriority (ThreadPriority prio);
31
32        void (*routine) (void *arg);
33        void *arg;
34
35    #ifdef WIN32
36        HANDLE th;
37        ULONG id;
38    #else
39        pthread_t tid;
40    #endif
41
42};
43
44class MMutex :  public Base
45{
46    public:
47
48    #ifdef WIN32
49        HANDLE sem;
50    #else
51        pthread_mutex_t mutex;
52        static pthread_mutexattr_t attr;
53        static int attr_refcount;
54    #endif
55        static MMutex *Create ();
56        MMutex ();
57        virtual ~MMutex ();
58        virtual bool Lock ();
59        virtual bool TryLock ();
60        virtual void Unlock ();
61};
62#endif                                                      // MTHREAD_H
Note: See TracBrowser for help on using the browser.