author | simon <simon> | 2002-12-02 19:31:37 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 19:31:37 (UTC) |
commit | a45bd312c97a83fef9b3d93c7caedb1f302c6ebe (patch) (unidiff) | |
tree | 0258962981573e1d9fd5e5453026b068136e4839 | |
parent | 618f271eff61003b66eb4a216826d8d52e1be627 (diff) | |
download | opie-a45bd312c97a83fef9b3d93c7caedb1f302c6ebe.zip opie-a45bd312c97a83fef9b3d93c7caedb1f302c6ebe.tar.gz opie-a45bd312c97a83fef9b3d93c7caedb1f302c6ebe.tar.bz2 |
- copyright fixlet
-rw-r--r-- | noncore/multimedia/opieplayer2/threadutil.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/threadutil.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/threadutil.cpp b/noncore/multimedia/opieplayer2/threadutil.cpp index 63863b4..4055c74 100644 --- a/noncore/multimedia/opieplayer2/threadutil.cpp +++ b/noncore/multimedia/opieplayer2/threadutil.cpp | |||
@@ -1,98 +1,98 @@ | |||
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project |
2 | Copyright (C) 1999 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 | #include "threadutil.h" | 20 | #include "threadutil.h" |
21 | 21 | ||
22 | #include <qsocketnotifier.h> | 22 | #include <qsocketnotifier.h> |
23 | 23 | ||
24 | #include <pthread.h> | 24 | #include <pthread.h> |
25 | #include <assert.h> | 25 | #include <assert.h> |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | 27 | ||
28 | using namespace ThreadUtil; | 28 | using namespace ThreadUtil; |
29 | 29 | ||
30 | struct Mutex::Data | 30 | struct Mutex::Data |
31 | { | 31 | { |
32 | Data() | 32 | Data() |
33 | { | 33 | { |
34 | pthread_mutex_init( &mutex, 0 ); | 34 | pthread_mutex_init( &mutex, 0 ); |
35 | } | 35 | } |
36 | ~Data() | 36 | ~Data() |
37 | { | 37 | { |
38 | pthread_mutex_destroy( &mutex ); | 38 | pthread_mutex_destroy( &mutex ); |
39 | } | 39 | } |
40 | 40 | ||
41 | pthread_mutex_t mutex; | 41 | pthread_mutex_t mutex; |
42 | }; | 42 | }; |
43 | 43 | ||
44 | Mutex::Mutex() | 44 | Mutex::Mutex() |
45 | : d( new Data ) | 45 | : d( new Data ) |
46 | { | 46 | { |
47 | } | 47 | } |
48 | 48 | ||
49 | Mutex::~Mutex() | 49 | Mutex::~Mutex() |
50 | { | 50 | { |
51 | delete d; | 51 | delete d; |
52 | } | 52 | } |
53 | 53 | ||
54 | void Mutex::lock() | 54 | void Mutex::lock() |
55 | { | 55 | { |
56 | pthread_mutex_lock( &d->mutex ); | 56 | pthread_mutex_lock( &d->mutex ); |
57 | } | 57 | } |
58 | 58 | ||
59 | void Mutex::unlock() | 59 | void Mutex::unlock() |
60 | { | 60 | { |
61 | pthread_mutex_unlock( &d->mutex ); | 61 | pthread_mutex_unlock( &d->mutex ); |
62 | } | 62 | } |
63 | 63 | ||
64 | bool Mutex::tryLock() | 64 | bool Mutex::tryLock() |
65 | { | 65 | { |
66 | return pthread_mutex_trylock( &d->mutex ) == 0; | 66 | return pthread_mutex_trylock( &d->mutex ) == 0; |
67 | } | 67 | } |
68 | 68 | ||
69 | bool Mutex::isLocked() | 69 | bool Mutex::isLocked() |
70 | { | 70 | { |
71 | if ( !tryLock() ) | 71 | if ( !tryLock() ) |
72 | return true; | 72 | return true; |
73 | 73 | ||
74 | unlock(); | 74 | unlock(); |
75 | return false; | 75 | return false; |
76 | } | 76 | } |
77 | 77 | ||
78 | struct WaitCondition::Data | 78 | struct WaitCondition::Data |
79 | { | 79 | { |
80 | Data() | 80 | Data() |
81 | { | 81 | { |
82 | int result = pthread_cond_init( &waitCondition, 0 ); | 82 | int result = pthread_cond_init( &waitCondition, 0 ); |
83 | assert( result == 0 ); | 83 | assert( result == 0 ); |
84 | } | 84 | } |
85 | ~Data() | 85 | ~Data() |
86 | { | 86 | { |
87 | pthread_cond_destroy( &waitCondition ); | 87 | pthread_cond_destroy( &waitCondition ); |
88 | } | 88 | } |
89 | 89 | ||
90 | pthread_cond_t waitCondition; | 90 | pthread_cond_t waitCondition; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | WaitCondition::WaitCondition() | 93 | WaitCondition::WaitCondition() |
94 | : d( new Data ) | 94 | : d( new Data ) |
95 | { | 95 | { |
96 | } | 96 | } |
97 | 97 | ||
98 | WaitCondition::~WaitCondition() | 98 | WaitCondition::~WaitCondition() |
diff --git a/noncore/multimedia/opieplayer2/threadutil.h b/noncore/multimedia/opieplayer2/threadutil.h index bcb9db9..5cc4cdc 100644 --- a/noncore/multimedia/opieplayer2/threadutil.h +++ b/noncore/multimedia/opieplayer2/threadutil.h | |||
@@ -1,98 +1,98 @@ | |||
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project |
2 | Copyright (C) 1999 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 | ||
27 | class QSocketNotifier; | 27 | class QSocketNotifier; |
28 | 28 | ||
29 | namespace ThreadUtil | 29 | namespace 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 OnewayNotifier : public QObject | 84 | class OnewayNotifier : public QObject |
85 | { | 85 | { |
86 | Q_OBJECT | 86 | Q_OBJECT |
87 | public: | 87 | public: |
88 | OnewayNotifier(); | 88 | OnewayNotifier(); |
89 | ~OnewayNotifier(); | 89 | ~OnewayNotifier(); |
90 | 90 | ||
91 | void notify(); | 91 | void notify(); |
92 | 92 | ||
93 | signals: | 93 | signals: |
94 | void awake(); | 94 | void awake(); |
95 | 95 | ||
96 | private slots: | 96 | private slots: |
97 | void wakeUp(); | 97 | void wakeUp(); |
98 | 98 | ||