summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-12-21 17:32:48 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-01-01 13:14:20 +0100
commit977e0bf1fc468976cf9b86df142807039623a71c (patch)
treea6991672c3d71f7b6f4d0917ea0fa3a9a5874bcc
parent34b67c5cb3338c4bd72f42df99a4b79ca1588071 (diff)
osl::Mutex->std::mutex in ThreadManager
Change-Id: I9a7ad88b77222c3419ab5eee0859ecc931d6b0aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127811 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/source/core/docnode/threadmanager.cxx13
-rw-r--r--sw/source/core/docnode/threadmanager.hxx8
2 files changed, 11 insertions, 10 deletions
diff --git a/sw/source/core/docnode/threadmanager.cxx b/sw/source/core/docnode/threadmanager.cxx
index 311c88e75a4d..20d71e746aea 100644
--- a/sw/source/core/docnode/threadmanager.cxx
+++ b/sw/source/core/docnode/threadmanager.cxx
@@ -71,7 +71,7 @@ oslInterlockedCount ThreadManager::AddThread(
const rtl::Reference< ObservableThread >& rThread )
{
- osl::MutexGuard aGuard(maMutex);
+ std::unique_lock aGuard(maMutex);
// create new thread
tThreadData aThreadData;
@@ -89,7 +89,7 @@ oslInterlockedCount ThreadManager::AddThread(
// add thread to manager
if ( maStartedThreads.size() < snStartedSize &&
- !StartingOfThreadsSuspended() )
+ !mbStartingOfThreadsSuspended )
{
// Try to start thread
if ( !StartThread( aThreadData ) )
@@ -116,7 +116,7 @@ void ThreadManager::RemoveThread( const oslInterlockedCount nThreadID,
const bool bThreadFinished )
{
// --> SAFE ----
- osl::MutexGuard aGuard(maMutex);
+ std::unique_lock aGuard(maMutex);
std::deque< tThreadData >::iterator aIter =
std::find_if( maStartedThreads.begin(), maStartedThreads.end(),
@@ -143,6 +143,7 @@ void ThreadManager::RemoveThread( const oslInterlockedCount nThreadID,
}
// Try to start thread from waiting ones
+ aGuard.unlock();
TryToStartNewThread( nullptr );
}
else
@@ -205,9 +206,9 @@ bool ThreadManager::StartThread( const tThreadData& rThreadData )
IMPL_LINK_NOARG(ThreadManager, TryToStartNewThread, Timer *, void)
{
- osl::MutexGuard aGuard(maMutex);
+ std::unique_lock aGuard(maMutex);
- if ( StartingOfThreadsSuspended() )
+ if ( mbStartingOfThreadsSuspended )
return;
// Try to start thread from waiting ones
@@ -225,7 +226,7 @@ IMPL_LINK_NOARG(ThreadManager, TryToStartNewThread, Timer *, void)
void ThreadManager::ResumeStartingOfThreads()
{
- osl::MutexGuard aGuard(maMutex);
+ std::unique_lock aGuard(maMutex);
mbStartingOfThreadsSuspended = false;
diff --git a/sw/source/core/docnode/threadmanager.hxx b/sw/source/core/docnode/threadmanager.hxx
index 87a3d8b0b93d..ace0bc03164b 100644
--- a/sw/source/core/docnode/threadmanager.hxx
+++ b/sw/source/core/docnode/threadmanager.hxx
@@ -20,7 +20,7 @@
#pragma once
#include <vcl/idle.hxx>
-#include <osl/mutex.hxx>
+#include <mutex>
#include <osl/interlck.h>
#include <rtl/ref.hxx>
@@ -79,7 +79,7 @@ class ThreadManager final
*/
void SuspendStartingOfThreads()
{
- osl::MutexGuard aGuard(maMutex);
+ std::unique_lock aGuard(maMutex);
mbStartingOfThreadsSuspended = true;
}
@@ -90,7 +90,7 @@ class ThreadManager final
bool StartingOfThreadsSuspended()
{
- osl::MutexGuard aGuard(maMutex);
+ std::unique_lock aGuard(maMutex);
return mbStartingOfThreadsSuspended;
}
@@ -111,7 +111,7 @@ class ThreadManager final
static const std::deque< tThreadData >::size_type snStartedSize;
- osl::Mutex maMutex;
+ std::mutex maMutex;
css::uno::WeakReference< css::util::XJobManager > mrThreadJoiner;