From 9b1c0e006f20091f28f3f468cfcab1feb51286bd Mon Sep 17 00:00:00 2001 From: Neo2003 Date: Thu, 2 Oct 2008 16:23:55 -0500 Subject: [svn] * Proper SVN structure --HG-- branch : trunk --- src/shared/Mthread.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/shared/Mthread.h (limited to 'src/shared/Mthread.h') diff --git a/src/shared/Mthread.h b/src/shared/Mthread.h new file mode 100644 index 00000000000..1afee4acd1b --- /dev/null +++ b/src/shared/Mthread.h @@ -0,0 +1,62 @@ +#ifndef MTHREAD_H +#define MTHREAD_H + +#include "Base.h" +#ifndef WIN32 +#include +#else +#include +//#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 -- cgit v1.2.3