summaryrefslogtreecommitdiff
path: root/ucbhelper/source
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-12-23 18:09:02 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-27 15:21:05 +0100
commit58a750598cb064f7d9a4569e80ce91f22a87512d (patch)
tree07f5e904d8aca1da89e3513673778b2ef23f2ee8 /ucbhelper/source
parent2a5b87316625d3f5cd735f01376c263dc40e7c81 (diff)
osl::Mutex->std::mutex in CommandProcessorInfo
Change-Id: I7de1e3e822b272fa4719c9113089c5e4852498ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127543 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucbhelper/source')
-rw-r--r--ucbhelper/source/provider/contentinfo.cxx51
-rw-r--r--ucbhelper/source/provider/contentinfo.hxx20
2 files changed, 32 insertions, 39 deletions
diff --git a/ucbhelper/source/provider/contentinfo.cxx b/ucbhelper/source/provider/contentinfo.cxx
index 76dfb68dbf6b..5ea61e825e8b 100644
--- a/ucbhelper/source/provider/contentinfo.cxx
+++ b/ucbhelper/source/provider/contentinfo.cxx
@@ -191,31 +191,30 @@ CommandProcessorInfo::~CommandProcessorInfo()
// virtual
-uno::Sequence< css::ucb::CommandInfo > SAL_CALL
-CommandProcessorInfo::getCommands()
+uno::Sequence< css::ucb::CommandInfo > SAL_CALL CommandProcessorInfo::getCommands()
{
- if ( !m_xCommands )
- {
- osl::MutexGuard aGuard( m_aMutex );
- if ( !m_xCommands )
- {
+ std::unique_lock aGuard( m_aMutex );
+ return getCommandsImpl();
+}
- // Get info for commands.
+const uno::Sequence< css::ucb::CommandInfo > & CommandProcessorInfo::getCommandsImpl()
+{
+ if ( m_xCommands )
+ return *m_xCommands;
+ // Get info for commands.
- try
- {
- m_xCommands = m_pContent->getCommands( m_xEnv );
- }
- catch ( uno::RuntimeException const & )
- {
- throw;
- }
- catch ( uno::Exception const & )
- {
- m_xCommands.emplace();
- }
- }
+ try
+ {
+ m_xCommands = m_pContent->getCommands( m_xEnv );
+ }
+ catch ( uno::RuntimeException const & )
+ {
+ throw;
+ }
+ catch ( uno::Exception const & )
+ {
+ m_xCommands.emplace();
}
return *m_xCommands;
}
@@ -268,7 +267,7 @@ sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByHandle( sal_Int32 Handle )
void CommandProcessorInfo::reset()
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
m_xCommands.reset();
}
@@ -277,9 +276,9 @@ bool CommandProcessorInfo::queryCommand(
std::u16string_view rName,
css::ucb::CommandInfo& rCommand )
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
- getCommands();
+ getCommandsImpl();
const css::ucb::CommandInfo* pCommands
= m_xCommands->getConstArray();
@@ -302,9 +301,9 @@ bool CommandProcessorInfo::queryCommand(
sal_Int32 nHandle,
css::ucb::CommandInfo& rCommand )
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
- getCommands();
+ getCommandsImpl();
const css::ucb::CommandInfo* pCommands = m_xCommands->getConstArray();
sal_Int32 nCount = m_xCommands->getLength();
diff --git a/ucbhelper/source/provider/contentinfo.hxx b/ucbhelper/source/provider/contentinfo.hxx
index 15a122d3c83d..eaff22c4ea05 100644
--- a/ucbhelper/source/provider/contentinfo.hxx
+++ b/ucbhelper/source/provider/contentinfo.hxx
@@ -26,7 +26,6 @@
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <cppuhelper/implbase.hxx>
-#include <osl/mutex.hxx>
#include <mutex>
namespace com::sun::star::ucb { class XCommandEnvironment; }
@@ -88,7 +87,7 @@ class CommandProcessorInfo :
m_xEnv;
std::optional<css::uno::Sequence< css::ucb::CommandInfo >>
m_xCommands;
- osl::Mutex m_aMutex;
+ std::mutex m_aMutex;
ContentImplHelper* m_pContent;
private:
@@ -96,6 +95,7 @@ private:
css::ucb::CommandInfo& rCommand );
bool queryCommand( sal_Int32 nHandle,
css::ucb::CommandInfo& rCommand );
+ const css::uno::Sequence< css::ucb::CommandInfo > & getCommandsImpl();
public:
CommandProcessorInfo( const css::uno::Reference< css::ucb::XCommandEnvironment >& rxEnv,
@@ -103,17 +103,11 @@ public:
virtual ~CommandProcessorInfo() override;
// XCommandInfo
- virtual css::uno::Sequence<
- css::ucb::CommandInfo > SAL_CALL
- getCommands() override;
- virtual css::ucb::CommandInfo SAL_CALL
- getCommandInfoByName( const OUString& Name ) override;
- virtual css::ucb::CommandInfo SAL_CALL
- getCommandInfoByHandle( sal_Int32 Handle ) override;
- virtual sal_Bool SAL_CALL
- hasCommandByName( const OUString& Name ) override;
- virtual sal_Bool SAL_CALL
- hasCommandByHandle( sal_Int32 Handle ) override;
+ virtual css::uno::Sequence< css::ucb::CommandInfo > SAL_CALL getCommands() override;
+ virtual css::ucb::CommandInfo SAL_CALL getCommandInfoByName( const OUString& Name ) override;
+ virtual css::ucb::CommandInfo SAL_CALL getCommandInfoByHandle( sal_Int32 Handle ) override;
+ virtual sal_Bool SAL_CALL hasCommandByName( const OUString& Name ) override;
+ virtual sal_Bool SAL_CALL hasCommandByHandle( sal_Int32 Handle ) override;
// Non-Interface methods.
void reset();