summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-02-14 09:39:21 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-02-14 12:34:58 +0000
commit1f59cbe6f0d879275ddd82dd0eaf224cbd1dec21 (patch)
treed969204c6b5dc438e9aebc1a6aad40e24cdb7443 /desktop
parent41c3c2dfaeee7fbd410fd76d4254ae9696a173a2 (diff)
osl::Mutex->std::atomic in DispatchWatcher
Change-Id: I7cad64f9031dd05e08321110ec670d3c744f03c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146971 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/app/dispatchwatcher.cxx18
-rw-r--r--desktop/source/app/dispatchwatcher.hxx5
2 files changed, 6 insertions, 17 deletions
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index 8ae45b40daa6..5b7fd944fee9 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -398,11 +398,8 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector<DispatchRequest
"unsupported dispatch request <" << aName << ">");
if( xDispatcher.is() )
{
- {
- osl::MutexGuard aGuard(m_mutex);
- // Remember request so we can find it in statusChanged!
- m_nRequestCount++;
- }
+ // Remember request so we can find it in statusChanged!
+ m_nRequestCount++;
// Use local vector to store dispatcher because we have to fill our request container before
// we can dispatch. Otherwise it would be possible that statusChanged is called before we dispatched all requests!!
@@ -770,18 +767,13 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector<DispatchRequest
xDisp->dispatchWithNotification( aDispatche.aURL, aArgs, this );
else
{
- {
- osl::MutexGuard aGuard(m_mutex);
- m_nRequestCount--;
- }
+ m_nRequestCount--;
xDispatch->dispatch( aDispatche.aURL, aArgs );
}
}
}
- ::osl::ClearableMutexGuard aGuard(m_mutex);
bool bEmpty = (m_nRequestCount == 0);
- aGuard.clear();
// No more asynchronous requests?
// The requests are removed from the request container after they called back to this
@@ -809,9 +801,7 @@ void SAL_CALL DispatchWatcher::disposing( const css::lang::EventObject& )
void SAL_CALL DispatchWatcher::dispatchFinished( const DispatchResultEvent& )
{
- osl::ClearableMutexGuard aGuard(m_mutex);
- sal_Int16 nCount = --m_nRequestCount;
- aGuard.clear();
+ int nCount = --m_nRequestCount;
RequestHandler::RequestsCompleted();
if ( !nCount && !RequestHandler::AreRequestsPending() )
{
diff --git a/desktop/source/app/dispatchwatcher.hxx b/desktop/source/app/dispatchwatcher.hxx
index 221cac915af3..70a7fd42e679 100644
--- a/desktop/source/app/dispatchwatcher.hxx
+++ b/desktop/source/app/dispatchwatcher.hxx
@@ -22,7 +22,7 @@
#include <cppuhelper/implbase.hxx>
#include <com/sun/star/frame/XDispatchResultListener.hpp>
#include <optional>
-
+#include <atomic>
#include <vector>
namespace desktop
@@ -77,9 +77,8 @@ class DispatchWatcher : public ::cppu::WeakImplHelper< css::frame::XDispatchResu
bool executeDispatchRequests( const std::vector<DispatchRequest>& aDispatches, bool bNoTerminate );
private:
- osl::Mutex m_mutex;
- sal_Int16 m_nRequestCount;
+ std::atomic<int> m_nRequestCount;
};
}