-rw-r--r-- | noncore/multimedia/opieplayer2/threadutil.cpp | 14 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/threadutil.h | 5 |
2 files changed, 9 insertions, 10 deletions
diff --git a/noncore/multimedia/opieplayer2/threadutil.cpp b/noncore/multimedia/opieplayer2/threadutil.cpp index a5cc92d..7a9e1a4 100644 --- a/noncore/multimedia/opieplayer2/threadutil.cpp +++ b/noncore/multimedia/opieplayer2/threadutil.cpp @@ -125,48 +125,48 @@ void WaitCondition::wakeAll() struct Thread::Data { Data() : isRunning( false ) {} pthread_t self; Mutex guard; bool isRunning; WaitCondition finishCondition; }; extern "C" { -void _threadutil_terminate_thread( void *arg ) +static void terminate_thread( void *arg ) { - Thread *thr = ( Thread* )arg; + Thread::Data *data = ( Thread::Data* )arg; - assert( thr ); + assert( data ); - AutoLock locker( thr->d->guard ); - thr->d->isRunning = false; - thr->d->finishCondition.wakeAll(); + AutoLock locker( data->guard ); + data->isRunning = false; + data->finishCondition.wakeAll(); } void *_threadutil_start_thread( void *arg ) { Thread *thr = ( Thread* )arg; - pthread_cleanup_push( _threadutil_terminate_thread, thr ); + pthread_cleanup_push( terminate_thread, thr->d ); thr->d->isRunning = true; thr->run(); pthread_cleanup_pop( true ); Thread::exit(); return 0; // never reached } } Thread::Thread() : d( new Data ) { } diff --git a/noncore/multimedia/opieplayer2/threadutil.h b/noncore/multimedia/opieplayer2/threadutil.h index b67b61d..21ae6b2 100644 --- a/noncore/multimedia/opieplayer2/threadutil.h +++ b/noncore/multimedia/opieplayer2/threadutil.h @@ -16,33 +16,32 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef THREADUTIL_H #define THREADUTIL_H #include <qvaluelist.h> #include <qobject.h> #include <qguardedptr.h> class QSocketNotifier; extern "C" { void *_threadutil_start_thread( void* ); - void _threadutil_terminate_thread( void* ); } namespace ThreadUtil { class Mutex { friend class WaitCondition; public: Mutex(); ~Mutex(); void lock(); void unlock(); bool tryLock(); bool isLocked(); @@ -77,50 +76,50 @@ namespace ThreadUtil bool wait( Mutex &mutex ); void wakeOne(); void wakeAll(); private: struct Data; Data *d; WaitCondition( const WaitCondition & ); WaitCondition &operator=( const WaitCondition & ); }; class Thread { friend void *::_threadutil_start_thread( void* ); - friend void ::_threadutil_terminate_thread( void* ); public: + struct Data; + Thread(); virtual ~Thread(); void start(); void terminate(); bool wait(); bool isRunning() const; static void exit(); protected: virtual void run() = 0; private: - struct Data; Data *d; }; class OnewayNotifier : public QObject { Q_OBJECT public: OnewayNotifier(); ~OnewayNotifier(); void notify(); signals: void awake(); private slots: |