diff options
-rw-r--r-- | avmedia/source/vlc/wrapper/EventHandler.cxx | 16 | ||||
-rw-r--r-- | avmedia/source/vlc/wrapper/EventHandler.hxx | 7 | ||||
-rw-r--r-- | avmedia/source/vlc/wrapper/ThreadsafeQueue.hxx | 11 |
3 files changed, 20 insertions, 14 deletions
diff --git a/avmedia/source/vlc/wrapper/EventHandler.cxx b/avmedia/source/vlc/wrapper/EventHandler.cxx index 6104d31fa0e4..188ccbc698c0 100644 --- a/avmedia/source/vlc/wrapper/EventHandler.cxx +++ b/avmedia/source/vlc/wrapper/EventHandler.cxx @@ -11,12 +11,18 @@ namespace VLC { -EventHandler::EventHandler( const char *name ) - : Thread( name ) +EventHandler::EventHandler() + : ::osl::Thread() { } -void EventHandler::execute() +void EventHandler::stop() +{ + mCallbackQueue.push(TCallback()); + join(); +} + +void EventHandler::run() { TCallback callback; do @@ -25,8 +31,8 @@ void EventHandler::execute() if ( callback.empty() ) return; - else - callback(); + + callback(); } while ( true ); } diff --git a/avmedia/source/vlc/wrapper/EventHandler.hxx b/avmedia/source/vlc/wrapper/EventHandler.hxx index f203e399ca99..fbf506987714 100644 --- a/avmedia/source/vlc/wrapper/EventHandler.hxx +++ b/avmedia/source/vlc/wrapper/EventHandler.hxx @@ -15,13 +15,14 @@ namespace VLC { - class EventHandler : public salhelper::Thread + class EventHandler : public ::osl::Thread { public: - EventHandler( const char* name ); + EventHandler(); + void stop(); protected: - virtual void execute(); + virtual void run(); public: typedef boost::function< void() > TCallback; diff --git a/avmedia/source/vlc/wrapper/ThreadsafeQueue.hxx b/avmedia/source/vlc/wrapper/ThreadsafeQueue.hxx index 7f428c42d2e8..52360d4bfe02 100644 --- a/avmedia/source/vlc/wrapper/ThreadsafeQueue.hxx +++ b/avmedia/source/vlc/wrapper/ThreadsafeQueue.hxx @@ -52,22 +52,21 @@ void ThreadsafeQueue<T>::push( const T& data ) { ::osl::MutexGuard guard( mMutex ); mQueue.push( data ); + mMutex.release(); mCondition.set(); } template<class T> void ThreadsafeQueue<T>::pop( T& data ) { - mMutex.acquire(); - if ( mQueue.empty() ) + mCondition.wait(); + ::osl::MutexGuard guard( mMutex ); + while ( mQueue.empty() ) { mMutex.release(); mCondition.wait(); - mCondition.reset(); + mMutex.acquire(); } - - ::osl::MutexGuard guard( mMutex ); - data = mQueue.front(); mQueue.pop(); } |