summaryrefslogtreecommitdiffstats
path: root/core/Thread.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/Thread.h')
-rw-r--r--core/Thread.h81
1 files changed, 38 insertions, 43 deletions
diff --git a/core/Thread.h b/core/Thread.h
index 0a09fabc9..58700aae1 100644
--- a/core/Thread.h
+++ b/core/Thread.h
@@ -1,13 +1,19 @@
-/* $Id: Thread.h,v 1.19 2003/10/09 16:03:51 titer Exp $
+/* $Id: Thread.h,v 1.3 2003/11/06 15:51:36 titer Exp $
This file is part of the HandBrake source code.
- Homepage: <http://beos.titer.org/handbrake/>.
+ Homepage: <http://handbrake.m0k.org/>.
It may be used under the terms of the GNU General Public License. */
#ifndef HB_THREAD_H
#define HB_THREAD_H
-#include "Common.h"
+#if defined( SYS_BEOS )
+# include <OS.h>
+#elif defined( SYS_MACOSX ) || defined( SYS_LINUX )
+# include <pthread.h>
+#endif
+
+#include "Utils.h"
#if defined( SYS_BEOS )
# define HB_LOW_PRIORITY 5
@@ -15,63 +21,52 @@
#elif defined( SYS_MACOSX )
# define HB_LOW_PRIORITY 0
# define HB_NORMAL_PRIORITY 31
-#elif defined( SYS_LINUX )
+#elif defined( SYS_LINUX ) || defined( SYS_CYGWIN )
/* Actually unused */
# define HB_LOW_PRIORITY 0
# define HB_NORMAL_PRIORITY 0
#endif
-class HBThread
-{
- public:
- HBThread( char * name,
- int priority = HB_LOW_PRIORITY );
- virtual ~HBThread();
- void Suspend();
- void Resume();
- int GetPid();
-
- protected:
- void Run();
- bool Push( HBFifo * fifo, HBBuffer * buffer );
- HBBuffer * Pop( HBFifo * fifo );
-
- volatile bool fDie;
- volatile bool fSuspend;
-
- private:
- static void ThreadFunc( HBThread * _this );
- virtual void DoWork();
-
- char * fName;
- int fPriority;
+HBThread * HBThreadInit( char * name, void (* function)(void *),
+ void * arg, int priority );
+void HBThreadClose( HBThread ** );
+struct HBLock
+{
#if defined( SYS_BEOS )
- int fThread;
+ sem_id sem;
#elif defined( SYS_MACOSX ) || defined( SYS_LINUX )
- pthread_t fThread;
+ pthread_mutex_t mutex;
+#elif defined( SYS_CYGWIN )
+ /* TODO */
#endif
- int fPid;
};
+HBLock * HBLockInit();
+static inline void HBLockLock( HBLock * );
+static inline void HBLockUnlock( HBLock * );
+void HBLockClose( HBLock ** );
+
+static inline void HBLockLock( HBLock * l )
+{
#if defined( SYS_BEOS )
-class BLocker;
+ acquire_sem( l->sem );
+#elif defined( SYS_MACOSX ) || defined( SYS_LINUX )
+ pthread_mutex_lock( &l->mutex );
+#elif defined( SYS_CYGWIN )
+ /* TODO */
#endif
+}
-class HBLock
+static inline void HBLockUnlock( HBLock * l )
{
- public:
- HBLock();
- ~HBLock();
- void Lock();
- void Unlock();
-
- private:
#if defined( SYS_BEOS )
- BLocker * fLocker;
+ release_sem( l->sem );
#elif defined( SYS_MACOSX ) || defined( SYS_LINUX )
- pthread_mutex_t fMutex;
+ pthread_mutex_unlock( &l->mutex );
+#elif defined( SYS_CYGWIN )
+ /* TODO */
#endif
-};
+}
#endif