diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-08-18 08:15:29 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-08-18 08:16:18 +0200 |
commit | 2861d5bedcc1c4f57c69faf86c5b18ce15049d06 (patch) | |
tree | 3b553ed310ac9fe176d9c457fcbf213b53c2d44b /cppu/source/threadpool | |
parent | 5d6ef74eea5d73b8cd17f313ad87138d56dc76ce (diff) |
Some oslCondition -> osl::Condition
Change-Id: I86cfbefd1cb8b22fca659a158b8e31d5c991de7a
Diffstat (limited to 'cppu/source/threadpool')
-rw-r--r-- | cppu/source/threadpool/jobqueue.cxx | 22 | ||||
-rw-r--r-- | cppu/source/threadpool/jobqueue.hxx | 5 | ||||
-rw-r--r-- | cppu/source/threadpool/threadpool.cxx | 16 | ||||
-rw-r--r-- | cppu/source/threadpool/threadpool.hxx | 7 |
4 files changed, 22 insertions, 28 deletions
diff --git a/cppu/source/threadpool/jobqueue.cxx b/cppu/source/threadpool/jobqueue.cxx index ec7b932d7b11..c0fdd6249383 100644 --- a/cppu/source/threadpool/jobqueue.cxx +++ b/cppu/source/threadpool/jobqueue.cxx @@ -28,19 +28,11 @@ namespace cppu_threadpool { JobQueue::JobQueue() : m_nToDo( 0 ), - m_bSuspended( false ), - m_cndWait( osl_createCondition() ) + m_bSuspended( false ) { - osl_resetCondition( m_cndWait ); m_DisposedCallerAdmin = DisposedCallerAdmin::getInstance(); } - JobQueue::~JobQueue() - { - osl_destroyCondition( m_cndWait ); - } - - void JobQueue::add( void *pThreadSpecificData, RequestFun * doRequest ) { MutexGuard guard( m_mutex ); @@ -48,7 +40,7 @@ namespace cppu_threadpool { m_lstJob.push_back( job ); if( ! m_bSuspended ) { - osl_setCondition( m_cndWait ); + m_cndWait.set(); } m_nToDo ++; } @@ -78,7 +70,7 @@ namespace cppu_threadpool { } } - osl_waitCondition( m_cndWait , 0 ); + m_cndWait.wait(); struct Job job={0,0}; { @@ -92,7 +84,7 @@ namespace cppu_threadpool { && (m_lstCallstack.empty() || m_lstCallstack.front() != 0) ) { - osl_resetCondition( m_cndWait ); + m_cndWait.reset(); } break; } @@ -106,7 +98,7 @@ namespace cppu_threadpool { if( m_lstJob.empty() && (m_lstCallstack.empty() || m_lstCallstack.front() != 0) ) { - osl_resetCondition( m_cndWait ); + m_cndWait.reset(); } } @@ -150,7 +142,7 @@ namespace cppu_threadpool { if( !m_lstCallstack.empty() && ! m_lstCallstack.front() ) { // The thread is waiting for a disposed pCallerId, let it go - osl_setCondition( m_cndWait ); + m_cndWait.set(); } } @@ -166,7 +158,7 @@ namespace cppu_threadpool { m_bSuspended = false; if( ! m_lstJob.empty() ) { - osl_setCondition( m_cndWait ); + m_cndWait.set(); } } diff --git a/cppu/source/threadpool/jobqueue.hxx b/cppu/source/threadpool/jobqueue.hxx index 1fffa64fb515..3a55d6b2a82c 100644 --- a/cppu/source/threadpool/jobqueue.hxx +++ b/cppu/source/threadpool/jobqueue.hxx @@ -23,7 +23,7 @@ #include <list> #include <sal/types.h> -#include <osl/conditn.h> +#include <osl/conditn.hxx> #include <osl/mutex.hxx> #include <boost/shared_ptr.hpp> @@ -49,7 +49,6 @@ namespace cppu_threadpool { public: JobQueue(); - ~JobQueue(); void add( void *pThreadSpecificData, RequestFun * doRequest ); @@ -69,7 +68,7 @@ namespace cppu_threadpool CallStackList m_lstCallstack; sal_Int32 m_nToDo; bool m_bSuspended; - oslCondition m_cndWait; + osl::Condition m_cndWait; DisposedCallerAdminHolder m_DisposedCallerAdmin; }; } diff --git a/cppu/source/threadpool/threadpool.cxx b/cppu/source/threadpool/threadpool.cxx index 965afcec3527..6e7a2c06363a 100644 --- a/cppu/source/threadpool/threadpool.cxx +++ b/cppu/source/threadpool/threadpool.cxx @@ -39,6 +39,10 @@ using namespace ::rtl; namespace cppu_threadpool { + WaitingThread::WaitingThread( + rtl::Reference<ORequestThread> const & theThread): thread(theThread) + {} + struct theDisposedCallerAdmin : public rtl::StaticWithInit< DisposedCallerAdminHolder, theDisposedCallerAdmin > { @@ -138,9 +142,7 @@ namespace cppu_threadpool ******************/ void ThreadPool::waitInPool( rtl::Reference< ORequestThread > const & pThread ) { - struct WaitingThread waitingThread; - waitingThread.condition = osl_createCondition(); - waitingThread.thread = pThread; + WaitingThread waitingThread(pThread); { MutexGuard guard( m_mutexWaitingThreadList ); m_lstThreads.push_front( &waitingThread ); @@ -148,7 +150,7 @@ namespace cppu_threadpool // let the thread wait 2 seconds TimeValue time = { 2 , 0 }; - osl_waitCondition( waitingThread.condition , &time ); + waitingThread.condition.wait( &time ); { MutexGuard guard ( m_mutexWaitingThreadList ); @@ -161,8 +163,6 @@ namespace cppu_threadpool m_lstThreads.erase( ii ); } } - - osl_destroyCondition( waitingThread.condition ); } void ThreadPool::joinWorkers() @@ -174,7 +174,7 @@ namespace cppu_threadpool ++ ii ) { // wake the threads up - osl_setCondition( (*ii)->condition ); + (*ii)->condition.set(); } } m_aThreadAdmin.join(); @@ -198,7 +198,7 @@ namespace cppu_threadpool m_lstThreads.pop_back(); // let the thread go - osl_setCondition( pWaitingThread->condition ); + pWaitingThread->condition.set(); return true; } } diff --git a/cppu/source/threadpool/threadpool.hxx b/cppu/source/threadpool/threadpool.hxx index dc17d6490ac8..b13dc0f31d2b 100644 --- a/cppu/source/threadpool/threadpool.hxx +++ b/cppu/source/threadpool/threadpool.hxx @@ -23,7 +23,7 @@ #include <list> #include <unordered_map> -#include <osl/conditn.h> +#include <osl/conditn.hxx> #include <rtl/byteseq.hxx> #include <rtl/ref.hxx> @@ -70,8 +70,11 @@ namespace cppu_threadpool { struct WaitingThread { - oslCondition condition; + osl::Condition condition; rtl::Reference< ORequestThread > thread; + + explicit WaitingThread( + rtl::Reference<ORequestThread> const & theThread); }; typedef ::std::list < struct ::cppu_threadpool::WaitingThread * > WaitingThreadList; |