diff options
author | handbrake <[email protected]> | 2006-01-14 12:53:59 +0000 |
---|---|---|
committer | handbrake <[email protected]> | 2006-01-14 12:53:59 +0000 |
commit | a9a84221af31ca7d11d1aa182d8b152270203f9f (patch) | |
tree | da452de9a4d3bb509d59de4a65fe12e9fb8e7825 /core/Thread.h | |
parent | 939b35fc70bb688d38b086afebd8d14d8193d2c9 (diff) |
HandBrake 0.3
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'core/Thread.h')
-rw-r--r-- | core/Thread.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/core/Thread.h b/core/Thread.h new file mode 100644 index 000000000..6afd59f53 --- /dev/null +++ b/core/Thread.h @@ -0,0 +1,76 @@ +/* $Id: Thread.h,v 1.16 2003/10/01 21:17:17 titer Exp $ + + This file is part of the HandBrake source code. + Homepage: <http://beos.titer.org/handbrake/>. + 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 ) +# define HB_LOW_PRIORITY 5 +# define HB_NORMAL_PRIORITY 10 +#elif defined( SYS_MACOSX ) +# define HB_LOW_PRIORITY (-47) +# define HB_NORMAL_PRIORITY (-47) /* FIXME */ +#elif defined( SYS_LINUX ) +/* 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 Run(); + void Stop(); + void Suspend(); + void Resume(); + + protected: + 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; + +#if defined( SYS_BEOS ) + int fThread; +#elif defined( SYS_MACOSX ) || defined( SYS_LINUX ) + pthread_t fThread; +#endif +}; + +#if defined( SYS_BEOS ) +class BLocker; +#endif + +class HBLock +{ + public: + HBLock(); + ~HBLock(); + void Lock(); + void Unlock(); + + private: +#if defined( SYS_BEOS ) + BLocker * fLocker; +#elif defined( SYS_MACOSX ) || defined( SYS_LINUX ) + pthread_mutex_t fMutex; +#endif +}; + +#endif |