author | simon <simon> | 2002-12-11 01:41:39 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 01:41:39 (UTC) |
commit | 2318caf33bf03acfbcbc0ccce61e3e7ff0aac4aa (patch) (side-by-side diff) | |
tree | 0fd4ed36dd54f26d730394fcef85704e04c06842 | |
parent | 3ec7f32d0924c737664a6ad4dfb43dc3c20605d0 (diff) | |
download | opie-2318caf33bf03acfbcbc0ccce61e3e7ff0aac4aa.zip opie-2318caf33bf03acfbcbc0ccce61e3e7ff0aac4aa.tar.gz opie-2318caf33bf03acfbcbc0ccce61e3e7ff0aac4aa.tar.bz2 |
- added bool Thread::isRunning() const
-rw-r--r-- | noncore/multimedia/opieplayer2/threadutil.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/threadutil.h | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/threadutil.cpp b/noncore/multimedia/opieplayer2/threadutil.cpp index 5687f42..a5cc92d 100644 --- a/noncore/multimedia/opieplayer2/threadutil.cpp +++ b/noncore/multimedia/opieplayer2/threadutil.cpp @@ -195,48 +195,54 @@ void Thread::start() pthread_attr_destroy( &attributes ); return; } pthread_attr_destroy( &attributes ); } void Thread::terminate() { AutoLock lock( d->guard ); if ( !d->isRunning ) return; pthread_cancel( d->self ); } bool Thread::wait() { AutoLock lock( d->guard ); if ( !d->isRunning ) return true; return d->finishCondition.wait( d->guard ); } +bool Thread::isRunning() const +{ + AutoLock lock( d->guard ); + return d->isRunning; +} + void Thread::exit() { pthread_exit( 0 ); } OnewayNotifier::OnewayNotifier() { int fds[ 2 ]; pipe( fds ); m_readFd = fds[ 0 ]; m_writeFd = fds[ 1 ]; m_notifier = new QSocketNotifier( m_readFd, QSocketNotifier::Read ); connect( m_notifier, SIGNAL( activated( int ) ), this, SLOT( wakeUp() ) ); } OnewayNotifier::~OnewayNotifier() { delete m_notifier; ::close( m_readFd ); ::close( m_writeFd ); } diff --git a/noncore/multimedia/opieplayer2/threadutil.h b/noncore/multimedia/opieplayer2/threadutil.h index b537cc1..b67b61d 100644 --- a/noncore/multimedia/opieplayer2/threadutil.h +++ b/noncore/multimedia/opieplayer2/threadutil.h @@ -79,48 +79,50 @@ namespace ThreadUtil 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: 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: void wakeUp(); |