summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-02-16 20:06:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-02-17 07:20:13 +0000
commitf8dc080dd021e352054d41b3c3f34e46028ecf5a (patch)
tree6e66fd915fcf40265956f159465692c8c3b9bbf5 /ucb
parentc19ef6d5edc0cf0a26e82752a71e1d1e01f08db7 (diff)
osl::Mutex->std::mutex in SortedDynamicResultSet
Change-Id: I21b98831645e2d7942bdf630225c136f9af3dca3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147189 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/sorter/sortdynres.cxx44
-rw-r--r--ucb/source/sorter/sortdynres.hxx6
2 files changed, 19 insertions, 31 deletions
diff --git a/ucb/source/sorter/sortdynres.cxx b/ucb/source/sorter/sortdynres.cxx
index 2f7039b55a0a..fe142c2b53f4 100644
--- a/ucb/source/sorter/sortdynres.cxx
+++ b/ucb/source/sorter/sortdynres.cxx
@@ -36,15 +36,6 @@ using namespace com::sun::star::uno;
using namespace comphelper;
-// The mutex to synchronize access to containers.
-static osl::Mutex& getContainerMutex()
-{
- static osl::Mutex ourMutex;
-
- return ourMutex;
-}
-
-
// SortedDynamicResultSet
SortedDynamicResultSet::SortedDynamicResultSet(
@@ -53,7 +44,6 @@ SortedDynamicResultSet::SortedDynamicResultSet(
const Reference < XAnyCompareFactory > &xCompFac,
const Reference < XComponentContext > &rxContext )
{
- mpDisposeEventListeners = nullptr;
mxOwnListener = new SortedDynamicResultSetListener( this );
mxOriginal = xOriginal;
@@ -72,7 +62,10 @@ SortedDynamicResultSet::~SortedDynamicResultSet()
mxOwnListener->impl_OwnerDies();
mxOwnListener.clear();
- mpDisposeEventListeners.reset();
+ {
+ std::unique_lock aGuard(maMutex);
+ maDisposeEventListeners.clear(aGuard);
+ }
mxOne.clear();
mxTwo.clear();
@@ -100,13 +93,13 @@ css::uno::Sequence< OUString > SAL_CALL SortedDynamicResultSet::getSupportedServ
void SAL_CALL SortedDynamicResultSet::dispose()
{
- osl::Guard< osl::Mutex > aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
- if ( mpDisposeEventListeners && mpDisposeEventListeners->getLength() )
+ if ( maDisposeEventListeners.getLength(aGuard) )
{
EventObject aEvt;
aEvt.Source = static_cast< XComponent * >( this );
- mpDisposeEventListeners->disposeAndClear( aEvt );
+ maDisposeEventListeners.disposeAndClear( aGuard, aEvt );
}
mxOne.clear();
@@ -119,22 +112,17 @@ void SAL_CALL SortedDynamicResultSet::dispose()
void SAL_CALL SortedDynamicResultSet::addEventListener(
const Reference< XEventListener >& Listener )
{
- osl::Guard< osl::Mutex > aGuard( maMutex );
-
- if ( !mpDisposeEventListeners )
- mpDisposeEventListeners.reset(
- new OInterfaceContainerHelper3<XEventListener>( getContainerMutex() ) );
+ std::unique_lock aGuard( maMutex );
- mpDisposeEventListeners->addInterface( Listener );
+ maDisposeEventListeners.addInterface( aGuard, Listener );
}
void SAL_CALL SortedDynamicResultSet::removeEventListener(
const Reference< XEventListener >& Listener )
{
- osl::Guard< osl::Mutex > aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
- if ( mpDisposeEventListeners )
- mpDisposeEventListeners->removeInterface( Listener );
+ maDisposeEventListeners.removeInterface( aGuard, Listener );
}
@@ -143,7 +131,7 @@ void SAL_CALL SortedDynamicResultSet::removeEventListener(
Reference< XResultSet > SAL_CALL
SortedDynamicResultSet::getStaticResultSet()
{
- osl::Guard< osl::Mutex > aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( mxListener.is() )
throw ListenerAlreadySetException();
@@ -163,12 +151,12 @@ SortedDynamicResultSet::getStaticResultSet()
void SAL_CALL
SortedDynamicResultSet::setListener( const Reference< XDynamicResultSetListener >& Listener )
{
- osl::Guard< osl::Mutex > aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
if ( mxListener.is() )
throw ListenerAlreadySetException();
- addEventListener( Listener );
+ maDisposeEventListeners.addInterface( aGuard, Listener );
mxListener = Listener;
@@ -211,7 +199,7 @@ SortedDynamicResultSet::connectToCache( const Reference< XDynamicResultSet > & x
sal_Int16 SAL_CALL SortedDynamicResultSet::getCapabilities()
{
- osl::Guard< osl::Mutex > aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
sal_Int16 nCaps = 0;
@@ -244,7 +232,7 @@ sal_Int16 SAL_CALL SortedDynamicResultSet::getCapabilities()
*/
void SortedDynamicResultSet::impl_notify( const ListEvent& Changes )
{
- osl::Guard< osl::Mutex > aGuard( maMutex );
+ std::unique_lock aGuard( maMutex );
bool bHasNew = false;
bool bHasModified = false;
diff --git a/ucb/source/sorter/sortdynres.hxx b/ucb/source/sorter/sortdynres.hxx
index 1098f223a6c1..320e4d9ddb8e 100644
--- a/ucb/source/sorter/sortdynres.hxx
+++ b/ucb/source/sorter/sortdynres.hxx
@@ -24,7 +24,7 @@
#include <com/sun/star/ucb/XDynamicResultSet.hpp>
#include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
-#include <comphelper/interfacecontainer3.hxx>
+#include <comphelper/interfacecontainer4.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implbase.hxx>
#include <memory>
@@ -38,7 +38,7 @@ class SortedDynamicResultSet: public cppu::WeakImplHelper <
css::lang::XServiceInfo,
css::ucb::XDynamicResultSet >
{
- std::unique_ptr<comphelper::OInterfaceContainerHelper3<css::lang::XEventListener>> mpDisposeEventListeners;
+ comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> maDisposeEventListeners;
css::uno::Reference < css::ucb::XDynamicResultSetListener > mxListener;
@@ -52,7 +52,7 @@ class SortedDynamicResultSet: public cppu::WeakImplHelper <
rtl::Reference<SortedDynamicResultSetListener> mxOwnListener;
EventList maActions;
- osl::Mutex maMutex;
+ std::mutex maMutex;
bool mbGotWelcome:1;
bool mbUseOne:1;
bool mbStatic:1;