[Libreoffice-commits] core.git: svl/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Tue Aug 24 06:39:38 UTC 2021
svl/source/fsstor/oinputstreamcontainer.cxx | 53 ++++++++++++----------------
svl/source/fsstor/oinputstreamcontainer.hxx | 8 ++--
2 files changed, 28 insertions(+), 33 deletions(-)
New commits:
commit f111a887a08295d56cdc1f20bc980bedbe17c67d
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sun Aug 22 18:42:20 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Aug 24 08:39:03 2021 +0200
osl::Mutex->std::mutex in OFSInputStreamContainer
Change-Id: Icd6ec9e6cd47fd0396cb70d6c63c435d7370b6fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120903
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svl/source/fsstor/oinputstreamcontainer.cxx b/svl/source/fsstor/oinputstreamcontainer.cxx
index d473911a1419..1339096dce9f 100644
--- a/svl/source/fsstor/oinputstreamcontainer.cxx
+++ b/svl/source/fsstor/oinputstreamcontainer.cxx
@@ -92,7 +92,7 @@ void SAL_CALL OFSInputStreamContainer::release()
sal_Int32 SAL_CALL OFSInputStreamContainer::readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
@@ -105,7 +105,7 @@ sal_Int32 SAL_CALL OFSInputStreamContainer::readBytes( uno::Sequence< sal_Int8 >
sal_Int32 SAL_CALL OFSInputStreamContainer::readSomeBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
@@ -118,7 +118,7 @@ sal_Int32 SAL_CALL OFSInputStreamContainer::readSomeBytes( uno::Sequence< sal_In
void SAL_CALL OFSInputStreamContainer::skipBytes( sal_Int32 nBytesToSkip )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
@@ -131,7 +131,7 @@ void SAL_CALL OFSInputStreamContainer::skipBytes( sal_Int32 nBytesToSkip )
sal_Int32 SAL_CALL OFSInputStreamContainer::available( )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
@@ -144,20 +144,21 @@ sal_Int32 SAL_CALL OFSInputStreamContainer::available( )
void SAL_CALL OFSInputStreamContainer::closeInput( )
{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( m_bDisposed )
- throw lang::DisposedException();
+ {
+ std::scoped_lock aGuard( m_aMutex );
- if ( !m_xInputStream.is() )
- throw uno::RuntimeException();
+ if ( m_bDisposed )
+ throw lang::DisposedException();
+ if ( !m_xInputStream.is() )
+ throw uno::RuntimeException();
+ }
dispose();
}
uno::Reference< io::XInputStream > SAL_CALL OFSInputStreamContainer::getInputStream()
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
@@ -170,7 +171,7 @@ uno::Reference< io::XInputStream > SAL_CALL OFSInputStreamContainer::getInputStr
uno::Reference< io::XOutputStream > SAL_CALL OFSInputStreamContainer::getOutputStream()
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
@@ -180,7 +181,7 @@ uno::Reference< io::XOutputStream > SAL_CALL OFSInputStreamContainer::getOutputS
void SAL_CALL OFSInputStreamContainer::seek( sal_Int64 location )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
@@ -193,7 +194,7 @@ void SAL_CALL OFSInputStreamContainer::seek( sal_Int64 location )
sal_Int64 SAL_CALL OFSInputStreamContainer::getPosition()
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
@@ -206,7 +207,7 @@ sal_Int64 SAL_CALL OFSInputStreamContainer::getPosition()
sal_Int64 SAL_CALL OFSInputStreamContainer::getLength()
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
@@ -219,7 +220,7 @@ sal_Int64 SAL_CALL OFSInputStreamContainer::getLength()
void SAL_CALL OFSInputStreamContainer::dispose( )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
@@ -229,37 +230,31 @@ void SAL_CALL OFSInputStreamContainer::dispose( )
m_xInputStream->closeInput();
- if ( m_pListenersContainer )
- {
- lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>( this ) );
- m_pListenersContainer->disposeAndClear( aSource );
- }
+ lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>( this ) );
+ m_aListenersContainer.disposeAndClear( aGuard, aSource );
+ aGuard.lock();
m_bDisposed = true;
}
void SAL_CALL OFSInputStreamContainer::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
- if ( !m_pListenersContainer )
- m_pListenersContainer.reset( new ::comphelper::OInterfaceContainerHelper2( m_aMutex ) );
-
- m_pListenersContainer->addInterface( xListener );
+ m_aListenersContainer.addInterface( xListener );
}
void SAL_CALL OFSInputStreamContainer::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ std::scoped_lock aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException();
- if ( m_pListenersContainer )
- m_pListenersContainer->removeInterface( xListener );
+ m_aListenersContainer.removeInterface( xListener );
}
diff --git a/svl/source/fsstor/oinputstreamcontainer.hxx b/svl/source/fsstor/oinputstreamcontainer.hxx
index a3bd9bcc1fb6..4dc2584d1256 100644
--- a/svl/source/fsstor/oinputstreamcontainer.hxx
+++ b/svl/source/fsstor/oinputstreamcontainer.hxx
@@ -26,16 +26,16 @@
#include <cppuhelper/implbase.hxx>
-#include <comphelper/interfacecontainer2.hxx>
+#include <comphelper/interfacecontainer4.hxx>
-#include <osl/mutex.hxx>
+#include <mutex>
#include <memory>
class OFSInputStreamContainer : public cppu::WeakImplHelper < css::io::XInputStream
,css::embed::XExtendedStorageStream >
, public css::io::XSeekable
{
- ::osl::Mutex m_aMutex;
+ std::mutex m_aMutex;
css::uno::Reference < css::io::XInputStream > m_xInputStream;
css::uno::Reference < css::io::XSeekable > m_xSeekable;
@@ -44,7 +44,7 @@ class OFSInputStreamContainer : public cppu::WeakImplHelper < css::io::XInputStr
bool m_bDisposed;
- std::unique_ptr<::comphelper::OInterfaceContainerHelper2> m_pListenersContainer; // list of listeners
+ ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aListenersContainer; // list of listeners
public:
explicit OFSInputStreamContainer( const css::uno::Reference < css::io::XInputStream >& xStream );
More information about the Libreoffice-commits
mailing list