summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 );
};
}