summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-11 11:25:20 (UTC)
committer simon <simon>2002-12-11 11:25:20 (UTC)
commit9431b69a1efab055c28c77e780df012b0a476a57 (patch) (unidiff)
tree999b06a41068cae5e109aaed3c7641e3013d4bb4
parent03535484e54b2b2311d9d44670b417e2b81ae63b (diff)
downloadopie-9431b69a1efab055c28c77e780df012b0a476a57.zip
opie-9431b69a1efab055c28c77e780df012b0a476a57.tar.gz
opie-9431b69a1efab055c28c77e780df012b0a476a57.tar.bz2
- removed unused variable
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/threadutil.h1
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/threadutil.h b/noncore/multimedia/opieplayer2/threadutil.h
index 1411535..2e83d3a 100644
--- a/noncore/multimedia/opieplayer2/threadutil.h
+++ b/noncore/multimedia/opieplayer2/threadutil.h
@@ -1,200 +1,199 @@
1/* This file is part of the KDE project 1/* This file is part of the KDE project
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef THREADUTIL_H 20#ifndef THREADUTIL_H
21#define THREADUTIL_H 21#define THREADUTIL_H
22 22
23#include <qvaluelist.h> 23#include <qvaluelist.h>
24#include <qobject.h> 24#include <qobject.h>
25#include <qguardedptr.h> 25#include <qguardedptr.h>
26 26
27class QSocketNotifier; 27class QSocketNotifier;
28 28
29namespace ThreadUtil 29namespace ThreadUtil
30{ 30{
31 31
32 class Mutex 32 class Mutex
33 { 33 {
34 friend class WaitCondition; 34 friend class WaitCondition;
35 public: 35 public:
36 Mutex(); 36 Mutex();
37 ~Mutex(); 37 ~Mutex();
38 38
39 void lock(); 39 void lock();
40 void unlock(); 40 void unlock();
41 bool tryLock(); 41 bool tryLock();
42 bool isLocked(); 42 bool isLocked();
43 43
44 private: 44 private:
45 struct Data; 45 struct Data;
46 Data *d; 46 Data *d;
47 47
48 Mutex( const Mutex & ); 48 Mutex( const Mutex & );
49 Mutex &operator=( const Mutex & ); 49 Mutex &operator=( const Mutex & );
50 }; 50 };
51 51
52 class AutoLock 52 class AutoLock
53 { 53 {
54 public: 54 public:
55 AutoLock( Mutex &mutex ) : m_mutex( mutex ) { m_mutex.lock(); } 55 AutoLock( Mutex &mutex ) : m_mutex( mutex ) { m_mutex.lock(); }
56 ~AutoLock() { m_mutex.unlock(); } 56 ~AutoLock() { m_mutex.unlock(); }
57 57
58 Mutex *operator &() const { return &m_mutex; } 58 Mutex *operator &() const { return &m_mutex; }
59 59
60 private: 60 private:
61 Mutex &m_mutex; 61 Mutex &m_mutex;
62 }; 62 };
63 63
64 class WaitCondition 64 class WaitCondition
65 { 65 {
66 public: 66 public:
67 WaitCondition(); 67 WaitCondition();
68 ~WaitCondition(); 68 ~WaitCondition();
69 69
70 bool wait(); 70 bool wait();
71 bool wait( Mutex &mutex ); 71 bool wait( Mutex &mutex );
72 72
73 void wakeOne(); 73 void wakeOne();
74 void wakeAll(); 74 void wakeAll();
75 75
76 private: 76 private:
77 struct Data; 77 struct Data;
78 Data *d; 78 Data *d;
79 79
80 WaitCondition( const WaitCondition & ); 80 WaitCondition( const WaitCondition & );
81 WaitCondition &operator=( const WaitCondition & ); 81 WaitCondition &operator=( const WaitCondition & );
82 }; 82 };
83 83
84 class Thread 84 class Thread
85 { 85 {
86 public: 86 public:
87 struct Data; 87 struct Data;
88 friend struct Data; 88 friend struct Data;
89 89
90 Thread(); 90 Thread();
91 virtual ~Thread(); 91 virtual ~Thread();
92 92
93 void start(); 93 void start();
94 void terminate(); 94 void terminate();
95 95
96 bool wait(); 96 bool wait();
97 97
98 bool isRunning() const; 98 bool isRunning() const;
99 99
100 static void exit(); 100 static void exit();
101 protected: 101 protected:
102 virtual void run() = 0; 102 virtual void run() = 0;
103 103
104 private: 104 private:
105 Data *d; 105 Data *d;
106 }; 106 };
107 107
108 class OnewayNotifier : public QObject 108 class OnewayNotifier : public QObject
109 { 109 {
110 Q_OBJECT 110 Q_OBJECT
111 public: 111 public:
112 OnewayNotifier(); 112 OnewayNotifier();
113 ~OnewayNotifier(); 113 ~OnewayNotifier();
114 114
115 void notify(); 115 void notify();
116 116
117 signals: 117 signals:
118 void awake(); 118 void awake();
119 119
120 private slots: 120 private slots:
121 void wakeUp(); 121 void wakeUp();
122 122
123 private: 123 private:
124 int m_readFd; 124 int m_readFd;
125 int m_writeFd; 125 int m_writeFd;
126 QSocketNotifier *m_notifier; 126 QSocketNotifier *m_notifier;
127 }; 127 };
128 128
129 129
130 class Channel; 130 class Channel;
131 131
132 class ChannelMessage 132 class ChannelMessage
133 { 133 {
134 friend class Channel; 134 friend class Channel;
135 public: 135 public:
136 ChannelMessage( int type = -1 ); 136 ChannelMessage( int type = -1 );
137 virtual ~ChannelMessage(); 137 virtual ~ChannelMessage();
138 138
139 int type() const { return m_type; } 139 int type() const { return m_type; }
140 140
141 void reply(); 141 void reply();
142 142
143 private: 143 private:
144 ChannelMessage( const ChannelMessage & ); 144 ChannelMessage( const ChannelMessage & );
145 ChannelMessage &operator=( const ChannelMessage ); 145 ChannelMessage &operator=( const ChannelMessage );
146 146
147 int m_type; 147 int m_type;
148 bool m_isCall : 1; 148 bool m_isCall : 1;
149 bool m_replied : 1; 149 bool m_replied : 1;
150 bool m_inEventHandler : 1; 150 bool m_inEventHandler : 1;
151 Mutex m_guard; 151 Mutex m_guard;
152 WaitCondition m_condition; 152 WaitCondition m_condition;
153 QGuardedPtr<Channel> m_channel;
154 }; 153 };
155 154
156 class Channel : public QObject 155 class Channel : public QObject
157 { 156 {
158 Q_OBJECT 157 Q_OBJECT
159 public: 158 public:
160 enum SendType { OneWay, WaitForReply }; 159 enum SendType { OneWay, WaitForReply };
161 Channel( QObject *parent = 0, const char *name = 0 ); 160 Channel( QObject *parent = 0, const char *name = 0 );
162 virtual ~Channel(); 161 virtual ~Channel();
163 162
164 void send( ChannelMessage *message, SendType type ); 163 void send( ChannelMessage *message, SendType type );
165 164
166 protected: 165 protected:
167 virtual void receiveMessage( ChannelMessage *message, SendType type ) = 0; 166 virtual void receiveMessage( ChannelMessage *message, SendType type ) = 0;
168 167
169 private slots: 168 private slots:
170 void deliver(); 169 void deliver();
171 170
172 private: 171 private:
173 OnewayNotifier m_notifier; 172 OnewayNotifier m_notifier;
174 173
175 struct MsgEnvelope 174 struct MsgEnvelope
176 { 175 {
177 MsgEnvelope() : type( OneWay ), msg( 0 ) {} 176 MsgEnvelope() : type( OneWay ), msg( 0 ) {}
178 MsgEnvelope( SendType _type , ChannelMessage *_msg ) 177 MsgEnvelope( SendType _type , ChannelMessage *_msg )
179 : type( _type ), msg( _msg ) {} 178 : type( _type ), msg( _msg ) {}
180 179
181 SendType type; 180 SendType type;
182 ChannelMessage *msg; 181 ChannelMessage *msg;
183 }; 182 };
184 183
185 void deliverOne( const MsgEnvelope &envelope ); 184 void deliverOne( const MsgEnvelope &envelope );
186 185
187 typedef QValueList<MsgEnvelope> MsgEnvelopeList; 186 typedef QValueList<MsgEnvelope> MsgEnvelopeList;
188 187
189 MsgEnvelopeList m_pendingMessages; 188 MsgEnvelopeList m_pendingMessages;
190 Mutex m_pendingMessagesGuard; 189 Mutex m_pendingMessagesGuard;
191 190
192 struct Private; 191 struct Private;
193 Private *d; 192 Private *d;
194 }; 193 };
195 194
196} 195}
197 196
198#endif // THREADUTIL_H 197#endif // THREADUTIL_H
199/* vim: et sw=4 ts=4 198/* vim: et sw=4 ts=4
200 */ 199 */