summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/threadutil.cpp14
-rw-r--r--noncore/multimedia/opieplayer2/threadutil.h5
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
@@ -133,32 +133,32 @@ struct Thread::Data
133 bool isRunning; 133 bool isRunning;
134 134
135 WaitCondition finishCondition; 135 WaitCondition finishCondition;
136}; 136};
137 137
138extern "C" 138extern "C"
139{ 139{
140 140
141void _threadutil_terminate_thread( void *arg ) 141static void terminate_thread( void *arg )
142{ 142{
143 Thread *thr = ( Thread* )arg; 143 Thread::Data *data = ( Thread::Data* )arg;
144 144
145 assert( thr ); 145 assert( data );
146 146
147 AutoLock locker( thr->d->guard ); 147 AutoLock locker( data->guard );
148 thr->d->isRunning = false; 148 data->isRunning = false;
149 thr->d->finishCondition.wakeAll(); 149 data->finishCondition.wakeAll();
150} 150}
151 151
152void *_threadutil_start_thread( void *arg ) 152void *_threadutil_start_thread( void *arg )
153{ 153{
154 Thread *thr = ( Thread* )arg; 154 Thread *thr = ( Thread* )arg;
155 155
156 pthread_cleanup_push( _threadutil_terminate_thread, thr ); 156 pthread_cleanup_push( terminate_thread, thr->d );
157 157
158 thr->d->isRunning = true; 158 thr->d->isRunning = true;
159 thr->run(); 159 thr->run();
160 160
161 pthread_cleanup_pop( true ); 161 pthread_cleanup_pop( true );
162 162
163 Thread::exit(); 163 Thread::exit();
164 return 0; // never reached 164 return 0; // never reached
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
@@ -24,17 +24,16 @@
24#include <qobject.h> 24#include <qobject.h>
25#include <qguardedptr.h> 25#include <qguardedptr.h>
26 26
27class QSocketNotifier; 27class QSocketNotifier;
28 28
29extern "C" 29extern "C"
30{ 30{
31 void *_threadutil_start_thread( void* ); 31 void *_threadutil_start_thread( void* );
32 void _threadutil_terminate_thread( void* );
33} 32}
34 33
35namespace ThreadUtil 34namespace ThreadUtil
36{ 35{
37 36
38 class Mutex 37 class Mutex
39 { 38 {
40 friend class WaitCondition; 39 friend class WaitCondition;
@@ -85,34 +84,34 @@ namespace ThreadUtil
85 84
86 WaitCondition( const WaitCondition & ); 85 WaitCondition( const WaitCondition & );
87 WaitCondition &operator=( const WaitCondition & ); 86 WaitCondition &operator=( const WaitCondition & );
88 }; 87 };
89 88
90 class Thread 89 class Thread
91 { 90 {
92 friend void *::_threadutil_start_thread( void* ); 91 friend void *::_threadutil_start_thread( void* );
93 friend void ::_threadutil_terminate_thread( void* );
94 public: 92 public:
93 struct Data;
94
95 Thread(); 95 Thread();
96 virtual ~Thread(); 96 virtual ~Thread();
97 97
98 void start(); 98 void start();
99 void terminate(); 99 void terminate();
100 100
101 bool wait(); 101 bool wait();
102 102
103 bool isRunning() const; 103 bool isRunning() const;
104 104
105 static void exit(); 105 static void exit();
106 protected: 106 protected:
107 virtual void run() = 0; 107 virtual void run() = 0;
108 108
109 private: 109 private:
110 struct Data;
111 Data *d; 110 Data *d;
112 }; 111 };
113 112
114 class OnewayNotifier : public QObject 113 class OnewayNotifier : public QObject
115 { 114 {
116 Q_OBJECT 115 Q_OBJECT
117 public: 116 public:
118 OnewayNotifier(); 117 OnewayNotifier();