From 05ab38359ae72f2a54dc0b5f1b84ac5f649c507a Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 3 Aug 2021 11:36:01 +0200 Subject: Consolidate on C++17 std::scoped_lock instead of std::lock_guard as in commit 9376f65a26240441bf9dd6ae1f69886dc9fa60fa Change-Id: I3ad9afd4d113582a214a4a4bc7eea55e38cd6ff9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119927 Tested-by: Jenkins Reviewed-by: Noel Grandin --- comphelper/source/container/namecontainer.cxx | 14 +++++++------- .../source/misc/accessiblekeybindinghelper.cxx | 8 ++++---- comphelper/source/misc/asyncnotification.cxx | 6 +++--- comphelper/source/streaming/oslfile2streamwrap.cxx | 6 +++--- comphelper/source/streaming/seekableinput.cxx | 16 ++++++++-------- comphelper/source/streaming/seqinputstreamserv.cxx | 18 +++++++++--------- comphelper/source/streaming/seqoutputstreamserv.cxx | 8 ++++---- comphelper/source/streaming/seqstream.cxx | 20 ++++++++++---------- 8 files changed, 48 insertions(+), 48 deletions(-) (limited to 'comphelper') diff --git a/comphelper/source/container/namecontainer.cxx b/comphelper/source/container/namecontainer.cxx index d175d25c3b37..c13ee7486e80 100644 --- a/comphelper/source/container/namecontainer.cxx +++ b/comphelper/source/container/namecontainer.cxx @@ -80,7 +80,7 @@ NameContainer::NameContainer( const css::uno::Type& aType ) // XNameContainer void SAL_CALL NameContainer::insertByName( const OUString& aName, const Any& aElement ) { - std::lock_guard aGuard( maMutex ); + std::scoped_lock aGuard( maMutex ); if( maProperties.find( aName ) != maProperties.end() ) throw ElementExistException(); @@ -93,7 +93,7 @@ void SAL_CALL NameContainer::insertByName( const OUString& aName, const Any& aEl void SAL_CALL NameContainer::removeByName( const OUString& Name ) { - std::lock_guard aGuard( maMutex ); + std::scoped_lock aGuard( maMutex ); SvGenericNameContainerMapImpl::iterator aIter = maProperties.find( Name ); if( aIter == maProperties.end() ) @@ -106,7 +106,7 @@ void SAL_CALL NameContainer::removeByName( const OUString& Name ) void SAL_CALL NameContainer::replaceByName( const OUString& aName, const Any& aElement ) { - std::lock_guard aGuard( maMutex ); + std::scoped_lock aGuard( maMutex ); SvGenericNameContainerMapImpl::iterator aIter( maProperties.find( aName ) ); if( aIter == maProperties.end() ) @@ -122,7 +122,7 @@ void SAL_CALL NameContainer::replaceByName( const OUString& aName, const Any& aE Any SAL_CALL NameContainer::getByName( const OUString& aName ) { - std::lock_guard aGuard( maMutex ); + std::scoped_lock aGuard( maMutex ); SvGenericNameContainerMapImpl::iterator aIter = maProperties.find( aName ); if( aIter == maProperties.end() ) @@ -133,14 +133,14 @@ Any SAL_CALL NameContainer::getByName( const OUString& aName ) Sequence< OUString > SAL_CALL NameContainer::getElementNames( ) { - std::lock_guard aGuard( maMutex ); + std::scoped_lock aGuard( maMutex ); return comphelper::mapKeysToSequence(maProperties); } sal_Bool SAL_CALL NameContainer::hasByName( const OUString& aName ) { - std::lock_guard aGuard( maMutex ); + std::scoped_lock aGuard( maMutex ); SvGenericNameContainerMapImpl::iterator aIter = maProperties.find( aName ); return aIter != maProperties.end(); @@ -148,7 +148,7 @@ sal_Bool SAL_CALL NameContainer::hasByName( const OUString& aName ) sal_Bool SAL_CALL NameContainer::hasElements( ) { - std::lock_guard aGuard( maMutex ); + std::scoped_lock aGuard( maMutex ); return !maProperties.empty(); } diff --git a/comphelper/source/misc/accessiblekeybindinghelper.cxx b/comphelper/source/misc/accessiblekeybindinghelper.cxx index c30cb3307d48..cf16f157c5e3 100644 --- a/comphelper/source/misc/accessiblekeybindinghelper.cxx +++ b/comphelper/source/misc/accessiblekeybindinghelper.cxx @@ -55,7 +55,7 @@ namespace comphelper void OAccessibleKeyBindingHelper::AddKeyBinding( const Sequence< awt::KeyStroke >& rKeyBinding ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); m_aKeyBindings.push_back( rKeyBinding ); } @@ -63,7 +63,7 @@ namespace comphelper void OAccessibleKeyBindingHelper::AddKeyBinding( const awt::KeyStroke& rKeyStroke ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); m_aKeyBindings.push_back( { rKeyStroke } ); } @@ -73,7 +73,7 @@ namespace comphelper sal_Int32 OAccessibleKeyBindingHelper::getAccessibleKeyBindingCount() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); return m_aKeyBindings.size(); } @@ -81,7 +81,7 @@ namespace comphelper Sequence< awt::KeyStroke > OAccessibleKeyBindingHelper::getAccessibleKeyBinding( sal_Int32 nIndex ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( nIndex < 0 || nIndex >= static_cast(m_aKeyBindings.size()) ) throw IndexOutOfBoundsException(); diff --git a/comphelper/source/misc/asyncnotification.cxx b/comphelper/source/misc/asyncnotification.cxx index 1a33c5a0b331..0c7f6391db8b 100644 --- a/comphelper/source/misc/asyncnotification.cxx +++ b/comphelper/source/misc/asyncnotification.cxx @@ -88,7 +88,7 @@ namespace comphelper void AsyncEventNotifierBase::removeEventsForProcessor( const ::rtl::Reference< IEventProcessor >& _xProcessor ) { - std::lock_guard aGuard( m_xImpl->aMutex ); + std::scoped_lock aGuard( m_xImpl->aMutex ); // remove all events for this processor m_xImpl->aEvents.erase(std::remove_if( m_xImpl->aEvents.begin(), m_xImpl->aEvents.end(), EqualProcessor( _xProcessor ) ), m_xImpl->aEvents.end()); @@ -97,7 +97,7 @@ namespace comphelper void SAL_CALL AsyncEventNotifierBase::terminate() { - std::lock_guard aGuard( m_xImpl->aMutex ); + std::scoped_lock aGuard( m_xImpl->aMutex ); // remember the termination request m_xImpl->bTerminate = true; @@ -109,7 +109,7 @@ namespace comphelper void AsyncEventNotifierBase::addEvent( const AnyEventRef& _rEvent, const ::rtl::Reference< IEventProcessor >& _xProcessor ) { - std::lock_guard aGuard( m_xImpl->aMutex ); + std::scoped_lock aGuard( m_xImpl->aMutex ); // remember this event m_xImpl->aEvents.emplace_back( ProcessableEvent {_rEvent, _xProcessor} ); diff --git a/comphelper/source/streaming/oslfile2streamwrap.cxx b/comphelper/source/streaming/oslfile2streamwrap.cxx index 472e085d642e..243634610c2b 100644 --- a/comphelper/source/streaming/oslfile2streamwrap.cxx +++ b/comphelper/source/streaming/oslfile2streamwrap.cxx @@ -53,7 +53,7 @@ sal_Int32 SAL_CALL OSLInputStreamWrapper::readBytes(css::uno::Sequence< sal_Int8 aData.realloc(nBytesToRead); - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); sal_uInt64 nRead = 0; FileBase::RC eError = m_pFile->read(static_cast(aData.getArray()), nBytesToRead, nRead); @@ -80,7 +80,7 @@ sal_Int32 SAL_CALL OSLInputStreamWrapper::readSomeBytes(css::uno::Sequence< sal_ void SAL_CALL OSLInputStreamWrapper::skipBytes(sal_Int32 nBytesToSkip) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if (!m_pFile) throw css::io::NotConnectedException(OUString(), static_cast(this)); @@ -97,7 +97,7 @@ void SAL_CALL OSLInputStreamWrapper::skipBytes(sal_Int32 nBytesToSkip) sal_Int32 SAL_CALL OSLInputStreamWrapper::available() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if (!m_pFile) throw css::io::NotConnectedException(OUString(), static_cast(this)); diff --git a/comphelper/source/streaming/seekableinput.cxx b/comphelper/source/streaming/seekableinput.cxx index e9291c6c9234..bd30aa354620 100644 --- a/comphelper/source/streaming/seekableinput.cxx +++ b/comphelper/source/streaming/seekableinput.cxx @@ -117,7 +117,7 @@ void OSeekableInputWrapper::PrepareCopy_Impl() sal_Int32 SAL_CALL OSeekableInputWrapper::readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xOriginalStream.is() ) throw io::NotConnectedException(); @@ -130,7 +130,7 @@ sal_Int32 SAL_CALL OSeekableInputWrapper::readBytes( uno::Sequence< sal_Int8 >& sal_Int32 SAL_CALL OSeekableInputWrapper::readSomeBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xOriginalStream.is() ) throw io::NotConnectedException(); @@ -143,7 +143,7 @@ sal_Int32 SAL_CALL OSeekableInputWrapper::readSomeBytes( uno::Sequence< sal_Int8 void SAL_CALL OSeekableInputWrapper::skipBytes( sal_Int32 nBytesToSkip ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xOriginalStream.is() ) throw io::NotConnectedException(); @@ -156,7 +156,7 @@ void SAL_CALL OSeekableInputWrapper::skipBytes( sal_Int32 nBytesToSkip ) sal_Int32 SAL_CALL OSeekableInputWrapper::available() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xOriginalStream.is() ) throw io::NotConnectedException(); @@ -169,7 +169,7 @@ sal_Int32 SAL_CALL OSeekableInputWrapper::available() void SAL_CALL OSeekableInputWrapper::closeInput() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xOriginalStream.is() ) throw io::NotConnectedException(); @@ -191,7 +191,7 @@ void SAL_CALL OSeekableInputWrapper::closeInput() void SAL_CALL OSeekableInputWrapper::seek( sal_Int64 location ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xOriginalStream.is() ) throw io::NotConnectedException(); @@ -204,7 +204,7 @@ void SAL_CALL OSeekableInputWrapper::seek( sal_Int64 location ) sal_Int64 SAL_CALL OSeekableInputWrapper::getPosition() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xOriginalStream.is() ) throw io::NotConnectedException(); @@ -217,7 +217,7 @@ sal_Int64 SAL_CALL OSeekableInputWrapper::getPosition() sal_Int64 SAL_CALL OSeekableInputWrapper::getLength() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xOriginalStream.is() ) throw io::NotConnectedException(); diff --git a/comphelper/source/streaming/seqinputstreamserv.cxx b/comphelper/source/streaming/seqinputstreamserv.cxx index d729fa7999c9..25596f17473c 100644 --- a/comphelper/source/streaming/seqinputstreamserv.cxx +++ b/comphelper/source/streaming/seqinputstreamserv.cxx @@ -103,7 +103,7 @@ uno::Sequence< OUString > SAL_CALL SequenceInputStreamService::getSupportedServi // css::io::XInputStream: ::sal_Int32 SAL_CALL SequenceInputStreamService::readBytes( uno::Sequence< ::sal_Int8 > & aData, ::sal_Int32 nBytesToRead ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xInputStream.is() ) throw io::NotConnectedException(); @@ -112,7 +112,7 @@ uno::Sequence< OUString > SAL_CALL SequenceInputStreamService::getSupportedServi ::sal_Int32 SAL_CALL SequenceInputStreamService::readSomeBytes( uno::Sequence< ::sal_Int8 > & aData, ::sal_Int32 nMaxBytesToRead ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xInputStream.is() ) throw io::NotConnectedException(); @@ -121,7 +121,7 @@ uno::Sequence< OUString > SAL_CALL SequenceInputStreamService::getSupportedServi void SAL_CALL SequenceInputStreamService::skipBytes( ::sal_Int32 nBytesToSkip ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xInputStream.is() ) throw io::NotConnectedException(); @@ -130,7 +130,7 @@ void SAL_CALL SequenceInputStreamService::skipBytes( ::sal_Int32 nBytesToSkip ) ::sal_Int32 SAL_CALL SequenceInputStreamService::available() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xInputStream.is() ) throw io::NotConnectedException(); @@ -139,7 +139,7 @@ void SAL_CALL SequenceInputStreamService::skipBytes( ::sal_Int32 nBytesToSkip ) void SAL_CALL SequenceInputStreamService::closeInput() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xInputStream.is() ) throw io::NotConnectedException(); @@ -151,7 +151,7 @@ void SAL_CALL SequenceInputStreamService::closeInput() // css::io::XSeekable: void SAL_CALL SequenceInputStreamService::seek( ::sal_Int64 location ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xSeekable.is() ) throw io::NotConnectedException(); @@ -160,7 +160,7 @@ void SAL_CALL SequenceInputStreamService::seek( ::sal_Int64 location ) ::sal_Int64 SAL_CALL SequenceInputStreamService::getPosition() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xSeekable.is() ) throw io::NotConnectedException(); @@ -169,7 +169,7 @@ void SAL_CALL SequenceInputStreamService::seek( ::sal_Int64 location ) ::sal_Int64 SAL_CALL SequenceInputStreamService::getLength() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xSeekable.is() ) throw io::NotConnectedException(); @@ -179,7 +179,7 @@ void SAL_CALL SequenceInputStreamService::seek( ::sal_Int64 location ) // css::lang::XInitialization: void SAL_CALL SequenceInputStreamService::initialize( const uno::Sequence< css::uno::Any > & aArguments ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( m_bInitialized ) throw frame::DoubleInitializationException(); diff --git a/comphelper/source/streaming/seqoutputstreamserv.cxx b/comphelper/source/streaming/seqoutputstreamserv.cxx index e19ea1001ae8..d1ffc4df2d42 100644 --- a/comphelper/source/streaming/seqoutputstreamserv.cxx +++ b/comphelper/source/streaming/seqoutputstreamserv.cxx @@ -90,7 +90,7 @@ uno::Sequence< OUString > SAL_CALL SequenceOutputStreamService::getSupportedServ // css::io::XOutputStream: void SAL_CALL SequenceOutputStreamService::writeBytes( const uno::Sequence< ::sal_Int8 > & aData ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xOutputStream.is() ) throw io::NotConnectedException(); @@ -99,7 +99,7 @@ void SAL_CALL SequenceOutputStreamService::writeBytes( const uno::Sequence< ::sa void SAL_CALL SequenceOutputStreamService::flush() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xOutputStream.is() ) throw io::NotConnectedException(); @@ -108,7 +108,7 @@ void SAL_CALL SequenceOutputStreamService::flush() void SAL_CALL SequenceOutputStreamService::closeOutput() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xOutputStream.is() ) throw io::NotConnectedException(); @@ -119,7 +119,7 @@ void SAL_CALL SequenceOutputStreamService::closeOutput() // css::io::XSequenceOutputStream: uno::Sequence< ::sal_Int8 > SAL_CALL SequenceOutputStreamService::getWrittenBytes() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if ( !m_xOutputStream.is() ) throw io::NotConnectedException(); diff --git a/comphelper/source/streaming/seqstream.cxx b/comphelper/source/streaming/seqstream.cxx index 9ad5db7254b8..db39a1dc30e8 100644 --- a/comphelper/source/streaming/seqstream.cxx +++ b/comphelper/source/streaming/seqstream.cxx @@ -60,7 +60,7 @@ sal_Int32 SAL_CALL SequenceInputStream::readBytes( Sequence& aData, sa if (nBytesToRead < 0) throw BufferSizeExceededException(OUString(),*this); - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); sal_Int32 nAvail = avail(); @@ -87,7 +87,7 @@ void SAL_CALL SequenceInputStream::skipBytes( sal_Int32 nBytesToSkip ) if (nBytesToSkip < 0) throw BufferSizeExceededException(OUString(),*this); - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); sal_Int32 nAvail = avail(); @@ -100,7 +100,7 @@ void SAL_CALL SequenceInputStream::skipBytes( sal_Int32 nBytesToSkip ) sal_Int32 SAL_CALL SequenceInputStream::available( ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); return avail(); } @@ -108,7 +108,7 @@ sal_Int32 SAL_CALL SequenceInputStream::available( ) void SAL_CALL SequenceInputStream::closeInput( ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); if (m_nPos == -1) throw NotConnectedException(OUString(), *this); @@ -120,19 +120,19 @@ void SAL_CALL SequenceInputStream::seek( sal_Int64 location ) { if ( location > m_aData.getLength() || location < 0 || location > SAL_MAX_INT32 ) throw IllegalArgumentException("bad location", static_cast(this), 1); - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); m_nPos = static_cast(location); } sal_Int64 SAL_CALL SequenceInputStream::getPosition() { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); return m_nPos; } sal_Int64 SAL_CALL SequenceInputStream::getLength( ) { - std::lock_guard aGuard( m_aMutex ); + std::scoped_lock aGuard( m_aMutex ); return m_aData.getLength(); } @@ -153,7 +153,7 @@ OSequenceOutputStream::OSequenceOutputStream(Sequence< sal_Int8 >& _rSeq, double void SAL_CALL OSequenceOutputStream::writeBytes( const Sequence< sal_Int8 >& _rData ) { - std::lock_guard aGuard(m_aMutex); + std::scoped_lock aGuard(m_aMutex); if (!m_bConnected) throw NotConnectedException(); @@ -193,7 +193,7 @@ void SAL_CALL OSequenceOutputStream::writeBytes( const Sequence< sal_Int8 >& _rD void SAL_CALL OSequenceOutputStream::flush( ) { - std::lock_guard aGuard(m_aMutex); + std::scoped_lock aGuard(m_aMutex); if (!m_bConnected) throw NotConnectedException(); @@ -211,7 +211,7 @@ void OSequenceOutputStream::finalizeOutput() void SAL_CALL OSequenceOutputStream::closeOutput() { - std::lock_guard aGuard(m_aMutex); + std::scoped_lock aGuard(m_aMutex); if (!m_bConnected) throw NotConnectedException(); -- cgit