summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-02-15 15:38:39 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-02-16 07:23:48 +0000
commit17827ea4974fce0a52d9986679223c670d9889ae (patch)
treed987b448ee5cb97c82ef849ae587e2d9e23d569c /unotools
parente8bb6e555cb4579ece3a9627d19a0a324620568a (diff)
osl::Mutex->std::mutex in UcbLockBytes
Change-Id: Ia84af116b705299ff4b9070f145e149c1a8a2c47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147101 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/ucbhelper/ucblockbytes.cxx16
-rw-r--r--unotools/source/ucbhelper/ucblockbytes.hxx15
2 files changed, 20 insertions, 11 deletions
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx
index 83ef4f75ad0a..ad5289f9310f 100644
--- a/unotools/source/ucbhelper/ucblockbytes.cxx
+++ b/unotools/source/ucbhelper/ucblockbytes.cxx
@@ -978,35 +978,39 @@ UcbLockBytes::~UcbLockBytes()
Reference < XInputStream > UcbLockBytes::getInputStream()
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
m_bDontClose = true;
return m_xInputStream;
}
void UcbLockBytes::setStream( const Reference<XStream>& aStream )
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
if ( aStream.is() )
{
m_xOutputStream = aStream->getOutputStream();
- setInputStream( aStream->getInputStream(), false );
+ setInputStreamImpl( aGuard, aStream->getInputStream(), false );
m_xSeekable.set( aStream, UNO_QUERY );
}
else
{
m_xOutputStream.clear();
- setInputStream( Reference < XInputStream >() );
+ setInputStreamImpl( aGuard, Reference < XInputStream >() );
}
}
bool UcbLockBytes::setInputStream( const Reference<XInputStream> &rxInputStream, bool bSetXSeekable )
{
+ std::unique_lock aGuard( m_aMutex );
+ return setInputStreamImpl(aGuard, rxInputStream, bSetXSeekable);
+}
+
+bool UcbLockBytes::setInputStreamImpl( std::unique_lock<std::mutex>& /*rGuard*/, const Reference<XInputStream> &rxInputStream, bool bSetXSeekable )
+{
bool bRet = false;
try
{
- osl::MutexGuard aGuard( m_aMutex );
-
if ( !m_bDontClose && m_xInputStream.is() )
m_xInputStream->closeInput();
diff --git a/unotools/source/ucbhelper/ucblockbytes.hxx b/unotools/source/ucbhelper/ucblockbytes.hxx
index 67a2d6216316..d866015b250f 100644
--- a/unotools/source/ucbhelper/ucblockbytes.hxx
+++ b/unotools/source/ucbhelper/ucblockbytes.hxx
@@ -21,9 +21,9 @@
#include <com/sun/star/uno/Reference.hxx>
#include <osl/conditn.hxx>
-#include <osl/mutex.hxx>
#include <tools/stream.hxx>
#include <comphelper/errcode.hxx>
+#include <mutex>
namespace com
{
@@ -63,7 +63,7 @@ class UcbLockBytes : public SvLockBytes
{
osl::Condition m_aInitialized;
osl::Condition m_aTerminated;
- osl::Mutex m_aMutex;
+ std::mutex m_aMutex;
css::uno::Reference < css::io::XInputStream > m_xInputStream;
css::uno::Reference < css::io::XOutputStream > m_xOutputStream;
@@ -112,19 +112,19 @@ public:
css::uno::Reference < css::io::XInputStream > getInputStream() const
{
- osl::MutexGuard aGuard( const_cast< UcbLockBytes* >(this)->m_aMutex );
+ std::unique_lock aGuard( const_cast< UcbLockBytes* >(this)->m_aMutex );
return m_xInputStream;
}
css::uno::Reference < css::io::XOutputStream > getOutputStream() const
{
- osl::MutexGuard aGuard( const_cast< UcbLockBytes* >(this)->m_aMutex );
+ std::unique_lock aGuard( const_cast< UcbLockBytes* >(this)->m_aMutex );
return m_xOutputStream;
}
css::uno::Reference < css::io::XSeekable > getSeekable() const
{
- osl::MutexGuard aGuard( const_cast< UcbLockBytes* >(this)->m_aMutex );
+ std::unique_lock aGuard( const_cast< UcbLockBytes* >(this)->m_aMutex );
return m_xSeekable;
}
@@ -132,6 +132,11 @@ public:
{ m_bDontClose = true; }
void SetStreamValid();
+
+private:
+ bool setInputStreamImpl( std::unique_lock<std::mutex>& rGuard,
+ const css::uno::Reference < css::io::XInputStream > &rxInputStream,
+ bool bSetXSeekable = true );
};
}