diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-02-27 20:43:29 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-02-27 20:53:20 +0100 |
commit | a860cd108c7e3e1eb0e5dfef6020610da1c07ed3 (patch) | |
tree | 823104e869cbd06222adeab3cd660cff1d1e60ea | |
parent | 3f43ebb4c3daf3e5c20a30a84f97bb4c93bff8a6 (diff) |
cppu: JobQueue::enter: add mutex guards for m_nToDo
Considered replacing it with oslInterlockedCount, but wondered why there is
no osl_getInterlockedCount (similar to glib's g_atomic_int_get)...
-rw-r--r-- | cppu/source/threadpool/jobqueue.cxx | 9 | ||||
-rw-r--r-- | cppu/source/threadpool/jobqueue.hxx | 6 |
2 files changed, 9 insertions, 6 deletions
diff --git a/cppu/source/threadpool/jobqueue.cxx b/cppu/source/threadpool/jobqueue.cxx index 08640572b678..da525ee006d5 100644 --- a/cppu/source/threadpool/jobqueue.cxx +++ b/cppu/source/threadpool/jobqueue.cxx @@ -122,12 +122,14 @@ namespace cppu_threadpool { if( job.doRequest ) { job.doRequest( job.pThreadSpecificData ); + MutexGuard guard( m_mutex ); m_nToDo --; } else { - m_nToDo --; pReturn = job.pThreadSpecificData; + MutexGuard guard( m_mutex ); + m_nToDo --; break; } } @@ -177,13 +179,13 @@ namespace cppu_threadpool { } } - sal_Bool JobQueue::isEmpty() + sal_Bool JobQueue::isEmpty() const { MutexGuard guard( m_mutex ); return m_lstJob.empty(); } - sal_Bool JobQueue::isCallstackEmpty() + sal_Bool JobQueue::isCallstackEmpty() const { MutexGuard guard( m_mutex ); return m_lstCallstack.empty(); @@ -191,6 +193,7 @@ namespace cppu_threadpool { sal_Bool JobQueue::isBusy() const { + MutexGuard guard( m_mutex ); return m_nToDo > 0; } diff --git a/cppu/source/threadpool/jobqueue.hxx b/cppu/source/threadpool/jobqueue.hxx index 6bddcc73483f..65f4a6075ea9 100644 --- a/cppu/source/threadpool/jobqueue.hxx +++ b/cppu/source/threadpool/jobqueue.hxx @@ -68,12 +68,12 @@ namespace cppu_threadpool void suspend(); void resume(); - sal_Bool isEmpty(); - sal_Bool isCallstackEmpty(); + sal_Bool isEmpty() const; + sal_Bool isCallstackEmpty() const; sal_Bool isBusy() const; private: - ::osl::Mutex m_mutex; + mutable ::osl::Mutex m_mutex; JobList m_lstJob; CallStackList m_lstCallstack; sal_Int32 m_nToDo; |