summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-07-21 20:49:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-07-22 11:40:54 +0200
commit7f7dad7018c874542e0ab6a0fb0f05f21d112b53 (patch)
treea7fc91dee69f1f747162b341749529106077df38
parentbebb1a3f2dc3e131f95a078f8a9c40d0491af7cd (diff)
simplify locking in configmgr
if we are going to have a shared lock, just use the instance of the shared lock instead of taking a shared_ptr to it. Change-Id: I00f74815426fcf971ff8e12734fc4566aa6ad5f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119343 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--configmgr/source/access.cxx94
-rw-r--r--configmgr/source/access.hxx2
-rw-r--r--configmgr/source/childaccess.cxx16
-rw-r--r--configmgr/source/childaccess.hxx1
-rw-r--r--configmgr/source/components.cxx11
-rw-r--r--configmgr/source/components.hxx1
-rw-r--r--configmgr/source/configurationprovider.cxx15
-rw-r--r--configmgr/source/defaultprovider.cxx2
-rw-r--r--configmgr/source/lock.cxx4
-rw-r--r--configmgr/source/lock.hxx3
-rw-r--r--configmgr/source/readonlyaccess.cxx2
-rw-r--r--configmgr/source/readwriteaccess.cxx2
-rw-r--r--configmgr/source/rootaccess.cxx17
-rw-r--r--configmgr/source/rootaccess.hxx2
-rw-r--r--configmgr/source/update.cxx10
15 files changed, 82 insertions, 100 deletions
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index 02e3f557c684..ec4b1f36e084 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -171,7 +171,7 @@ void Access::initBroadcaster(
css::uno::Sequence< css::uno::Type > Access::getTypes()
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
std::vector< css::uno::Type > types { cppu::UnoType< css::uno::XInterface >::get(),
cppu::UnoType< css::uno::XWeak >::get(),
@@ -222,7 +222,7 @@ css::uno::Sequence< css::uno::Type > Access::getTypes()
css::uno::Sequence< sal_Int8 > Access::getImplementationId()
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
return css::uno::Sequence< sal_Int8 >();
}
@@ -230,7 +230,7 @@ css::uno::Sequence< sal_Int8 > Access::getImplementationId()
OUString Access::getImplementationName()
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
return "org.openoffice-configmgr::Access";
}
@@ -243,7 +243,7 @@ sal_Bool Access::supportsService(OUString const & ServiceName)
css::uno::Sequence< OUString > Access::getSupportedServiceNames()
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
std::vector<OUString> services;
services.emplace_back("com.sun.star.configuration.ConfigurationAccess");
@@ -274,7 +274,7 @@ void Access::dispose() {
assert(thisIs(IS_ANY));
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
if (getParentAccess().is()) {
throw css::uno::RuntimeException(
@@ -296,7 +296,7 @@ void Access::addEventListener(
{
assert(thisIs(IS_ANY));
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
if (!xListener.is()) {
throw css::uno::RuntimeException(
@@ -317,7 +317,7 @@ void Access::removeEventListener(
css::uno::Reference< css::lang::XEventListener > const & aListener)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
DisposeListeners::iterator i(disposeListeners_.find(aListener));
if (i != disposeListeners_.end()) {
@@ -327,7 +327,7 @@ void Access::removeEventListener(
css::uno::Type Access::getElementType() {
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
rtl::Reference< Node > p(getNode());
switch (p->kind()) {
@@ -350,7 +350,7 @@ css::uno::Type Access::getElementType() {
sal_Bool Access::hasElements() {
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
return !getAllChildren().empty(); //TODO: optimize
}
@@ -394,7 +394,7 @@ bool Access::getByNameFast(const OUString & name, css::uno::Any & value)
css::uno::Any Access::getByName(OUString const & aName)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
css::uno::Any value;
if (!getByNameFast(aName, value))
@@ -406,7 +406,7 @@ css::uno::Any Access::getByName(OUString const & aName)
css::uno::Sequence< OUString > Access::getElementNames()
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
std::vector< rtl::Reference< ChildAccess > > children(getAllChildren());
std::vector<OUString> names;
@@ -421,7 +421,7 @@ css::uno::Sequence< OUString > Access::getElementNames()
sal_Bool Access::hasByName(OUString const & aName)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
return getChild(aName).is();
}
@@ -429,7 +429,7 @@ sal_Bool Access::hasByName(OUString const & aName)
css::uno::Any Access::getByHierarchicalName(OUString const & aName)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
rtl::Reference< ChildAccess > child(getSubChild(aName));
if (!child.is()) {
@@ -442,7 +442,7 @@ css::uno::Any Access::getByHierarchicalName(OUString const & aName)
sal_Bool Access::hasByHierarchicalName(OUString const & aName)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
return getSubChild(aName).is();
}
@@ -454,7 +454,7 @@ void Access::replaceByHierarchicalName(
assert(thisIs(IS_UPDATE));
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
rtl::Reference< ChildAccess > child(getSubChild(aName));
if (!child.is()) {
@@ -494,7 +494,7 @@ void Access::addContainerListener(
{
assert(thisIs(IS_ANY));
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
if (!xListener.is()) {
throw css::uno::RuntimeException(
@@ -515,7 +515,7 @@ void Access::removeContainerListener(
css::uno::Reference< css::container::XContainerListener > const & xListener)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
ContainerListeners::iterator i(containerListeners_.find(xListener));
if (i != containerListeners_.end()) {
@@ -526,7 +526,7 @@ void Access::removeContainerListener(
OUString Access::getExactName(OUString const & aApproximateName)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
return aApproximateName;
}
@@ -534,7 +534,7 @@ OUString Access::getExactName(OUString const & aApproximateName)
css::uno::Sequence< css::beans::Property > Access::getProperties()
{
assert(thisIs(IS_GROUP));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
std::vector< rtl::Reference< ChildAccess > > children(getAllChildren());
std::vector< css::beans::Property > properties;
properties.reserve(children.size());
@@ -548,7 +548,7 @@ css::uno::Sequence< css::beans::Property > Access::getProperties()
css::beans::Property Access::getPropertyByName(OUString const & aName)
{
assert(thisIs(IS_GROUP));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
rtl::Reference< ChildAccess > child(getChild(aName));
if (!child.is()) {
throw css::beans::UnknownPropertyException(
@@ -560,13 +560,13 @@ css::beans::Property Access::getPropertyByName(OUString const & aName)
sal_Bool Access::hasPropertyByName(OUString const & Name)
{
assert(thisIs(IS_GROUP));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
return getChild(Name).is();
}
OUString Access::getHierarchicalName() {
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
// For backwards compatibility, return an absolute path representation where
// available:
@@ -588,7 +588,7 @@ OUString Access::composeHierarchicalName(
OUString const & aRelativeName)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
if (aRelativeName.isEmpty() || aRelativeName[0] == '/') {
throw css::lang::IllegalArgumentException(
@@ -605,7 +605,7 @@ OUString Access::composeHierarchicalName(
OUString Access::getName() {
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
return getNameInternal();
}
@@ -615,7 +615,7 @@ void Access::setName(OUString const & aName)
assert(thisIs(IS_ANY));
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
checkFinalized();
Modifications localMods;
@@ -681,7 +681,7 @@ void Access::setName(OUString const & aName)
css::beans::Property Access::getAsProperty()
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
return asProperty();
}
@@ -698,7 +698,7 @@ void Access::setPropertyValue(
assert(thisIs(IS_GROUP));
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
if (!getRootAccess()->isUpdate()) {
throw css::uno::RuntimeException(
"configmgr setPropertyValue on non-update access",
@@ -717,7 +717,7 @@ void Access::setPropertyValue(
css::uno::Any Access::getPropertyValue(OUString const & PropertyName)
{
assert(thisIs(IS_GROUP));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
css::uno::Any value;
if (!getByNameFast(PropertyName, value))
@@ -733,7 +733,7 @@ void Access::addPropertyChangeListener(
{
assert(thisIs(IS_GROUP));
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
if (!xListener.is()) {
throw css::uno::RuntimeException(
"null listener", static_cast< cppu::OWeakObject * >(this));
@@ -756,7 +756,7 @@ void Access::removePropertyChangeListener(
aListener)
{
assert(thisIs(IS_GROUP));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkKnownProperty(aPropertyName);
PropertyChangeListeners::iterator i(
propertyChangeListeners_.find(aPropertyName));
@@ -778,7 +778,7 @@ void Access::addVetoableChangeListener(
{
assert(thisIs(IS_GROUP));
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
if (!aListener.is()) {
throw css::uno::RuntimeException(
"null listener", static_cast< cppu::OWeakObject * >(this));
@@ -802,7 +802,7 @@ void Access::removeVetoableChangeListener(
aListener)
{
assert(thisIs(IS_GROUP));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkKnownProperty(PropertyName);
VetoableChangeListeners::iterator i(
vetoableChangeListeners_.find(PropertyName));
@@ -824,7 +824,7 @@ void Access::setPropertyValues(
assert(thisIs(IS_GROUP));
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
if (!getRootAccess()->isUpdate()) {
throw css::uno::RuntimeException(
"configmgr setPropertyValues on non-update access",
@@ -853,7 +853,7 @@ css::uno::Sequence< css::uno::Any > Access::getPropertyValues(
css::uno::Sequence< OUString > const & aPropertyNames)
{
assert(thisIs(IS_GROUP));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
css::uno::Sequence< css::uno::Any > vals(aPropertyNames.getLength());
for (sal_Int32 i = 0; i < aPropertyNames.getLength(); ++i)
@@ -874,7 +874,7 @@ void Access::addPropertiesChangeListener(
{
assert(thisIs(IS_GROUP));
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
if (!xListener.is()) {
throw css::uno::RuntimeException(
"null listener", static_cast< cppu::OWeakObject * >(this));
@@ -895,7 +895,7 @@ void Access::removePropertiesChangeListener(
xListener)
{
assert(thisIs(IS_GROUP));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
PropertiesChangeListeners::iterator i(
propertiesChangeListeners_.find(xListener));
if (i != propertiesChangeListeners_.end()) {
@@ -933,7 +933,7 @@ void Access::setHierarchicalPropertyValue(
assert(thisIs(IS_GROUP));
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
if (!getRootAccess()->isUpdate()) {
throw css::uno::RuntimeException(
"configmgr setHierarchicalPropertyName on non-update access",
@@ -958,7 +958,7 @@ css::uno::Any Access::getHierarchicalPropertyValue(
OUString const & aHierarchicalPropertyName)
{
assert(thisIs(IS_GROUP));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
rtl::Reference< ChildAccess > child(getSubChild(aHierarchicalPropertyName));
if (!child.is()) {
throw css::beans::UnknownPropertyException(
@@ -975,7 +975,7 @@ void Access::setHierarchicalPropertyValues(
assert(thisIs(IS_GROUP));
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
if (!getRootAccess()->isUpdate()) {
throw css::uno::RuntimeException(
"configmgr setPropertyValues on non-update access",
@@ -1009,7 +1009,7 @@ css::uno::Sequence< css::uno::Any > Access::getHierarchicalPropertyValues(
css::uno::Sequence< OUString > const & aHierarchicalPropertyNames)
{
assert(thisIs(IS_GROUP));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
css::uno::Sequence< css::uno::Any > vals(
aHierarchicalPropertyNames.getLength());
for (sal_Int32 i = 0; i < aHierarchicalPropertyNames.getLength(); ++i) {
@@ -1030,7 +1030,7 @@ css::beans::Property Access::getPropertyByHierarchicalName(
OUString const & aHierarchicalName)
{
assert(thisIs(IS_GROUP));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
rtl::Reference< ChildAccess > child(getSubChild(aHierarchicalName));
if (!child.is()) {
throw css::beans::UnknownPropertyException(
@@ -1043,7 +1043,7 @@ sal_Bool Access::hasPropertyByHierarchicalName(
OUString const & aHierarchicalName)
{
assert(thisIs(IS_GROUP));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
return getSubChild(aHierarchicalName).is();
}
@@ -1053,7 +1053,7 @@ void Access::replaceByName(
assert(thisIs(IS_UPDATE));
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
rtl::Reference< ChildAccess > child(getChild(aName));
if (!child.is()) {
@@ -1093,7 +1093,7 @@ void Access::insertByName(
assert(thisIs(IS_EXTENSIBLE|IS_UPDATE));
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
checkFinalized();
if (getChild(aName).is()) {
@@ -1152,7 +1152,7 @@ void Access::removeByName(OUString const & aName)
assert(thisIs(IS_EXTENSIBLE|IS_UPDATE));
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
rtl::Reference< ChildAccess > child(getChild(aName));
if (!child.is() || child->isFinalized() ||
@@ -1213,7 +1213,7 @@ css::uno::Reference< css::uno::XInterface > Access::createInstanceWithArguments(
}
Access::Access(Components & components):
- components_(components), disposed_(false), lock_( lock() )
+ components_(components), disposed_(false)
{
}
@@ -2189,7 +2189,7 @@ rtl::Reference< Access > Access::getNotificationRoot() {
#if !defined NDEBUG
bool Access::thisIs(int what) {
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
rtl::Reference< Node > p(getNode());
Node::Kind k(p->kind());
return (k != Node::KIND_PROPERTY && k != Node::KIND_LOCALIZED_VALUE &&
diff --git a/configmgr/source/access.hxx b/configmgr/source/access.hxx
index 6d4ca787f3cc..d7cd90c11a6a 100644
--- a/configmgr/source/access.hxx
+++ b/configmgr/source/access.hxx
@@ -434,8 +434,6 @@ private:
PropertiesChangeListeners propertiesChangeListeners_;
bool disposed_;
- std::shared_ptr<osl::Mutex> lock_;
-
#if !defined NDEBUG
protected:
enum {
diff --git a/configmgr/source/childaccess.cxx b/configmgr/source/childaccess.cxx
index 41636b0e1bbe..d8bc0a640857 100644
--- a/configmgr/source/childaccess.cxx
+++ b/configmgr/source/childaccess.cxx
@@ -66,8 +66,7 @@ ChildAccess::ChildAccess(
rtl::Reference< Access > const & parent, OUString const & name,
rtl::Reference< Node > const & node):
Access(components), root_(root), parent_(parent), name_(name), node_(node),
- inTransaction_(false),
- lock_( lock() )
+ inTransaction_(false)
{
assert(root.is() && parent.is() && node.is());
}
@@ -75,8 +74,7 @@ ChildAccess::ChildAccess(
ChildAccess::ChildAccess(
Components & components, rtl::Reference< RootAccess > const & root,
rtl::Reference< Node > const & node):
- Access(components), root_(root), node_(node), inTransaction_(false),
- lock_( lock() )
+ Access(components), root_(root), node_(node), inTransaction_(false)
{
assert(root.is() && node.is());
}
@@ -144,7 +142,7 @@ void ChildAccess::release() noexcept {
css::uno::Reference< css::uno::XInterface > ChildAccess::getParent()
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
return static_cast< cppu::OWeakObject * >(parent_.get());
}
@@ -152,7 +150,7 @@ css::uno::Reference< css::uno::XInterface > ChildAccess::getParent()
void ChildAccess::setParent(css::uno::Reference< css::uno::XInterface > const &)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
throw css::lang::NoSupportException(
"setParent", static_cast< cppu::OWeakObject * >(this));
@@ -162,7 +160,7 @@ sal_Int64 ChildAccess::getSomething(
css::uno::Sequence< sal_Int8 > const & aIdentifier)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
return aIdentifier == getTunnelId()
? reinterpret_cast< sal_Int64 >(this) : 0;
@@ -310,7 +308,7 @@ void ChildAccess::commitChanges(bool valid, Modifications * globalModifications)
}
ChildAccess::~ChildAccess() {
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
if (parent_.is()) {
parent_->releaseChild(name_);
}
@@ -335,7 +333,7 @@ void ChildAccess::addSupportedServiceNames(
css::uno::Any ChildAccess::queryInterface(css::uno::Type const & aType)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
css::uno::Any res(Access::queryInterface(aType));
return res.hasValue()
diff --git a/configmgr/source/childaccess.hxx b/configmgr/source/childaccess.hxx
index 2aecdf6757ea..85d3b5bda4c7 100644
--- a/configmgr/source/childaccess.hxx
+++ b/configmgr/source/childaccess.hxx
@@ -128,7 +128,6 @@ private:
std::unique_ptr< css::uno::Any > changedValue_;
bool inTransaction_;
// to determine if a free node can be inserted underneath some root
- std::shared_ptr<osl::Mutex> lock_;
};
}
diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx
index 65bc00da9517..078de2cd3c3f 100644
--- a/configmgr/source/components.cxx
+++ b/configmgr/source/components.cxx
@@ -164,22 +164,20 @@ private:
OUString url_;
Data const & data_;
osl::Condition delay_;
- std::shared_ptr<osl::Mutex> lock_;
};
Components::WriteThread::WriteThread(
rtl::Reference< WriteThread > * reference, Components & components,
OUString const & url, Data const & data):
Thread("configmgrWriter"), reference_(reference), components_(components),
- url_(url), data_(data),
- lock_( lock() )
+ url_(url), data_(data)
{
assert(reference != nullptr);
}
void Components::WriteThread::execute() {
delay_.wait(std::chrono::seconds(1)); // must not throw; result_error is harmless and ignored
- osl::MutexGuard g(*lock_); // must not throw
+ osl::MutexGuard g(configmgr::GetLock()); // must not throw
try {
try {
writeModFile(components_, url_, data_);
@@ -295,7 +293,7 @@ void Components::writeModifications() {
void Components::flushModifications() {
rtl::Reference< WriteThread > thread;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
thread = writeThread_;
}
if (thread.is()) {
@@ -463,7 +461,6 @@ Components::Components(
modificationTarget_(ModificationTarget::None)
{
assert(context.is());
- lock_ = lock();
OUString conf(expand("${CONFIGURATION_LAYERS}"));
int layer = 0;
for (sal_Int32 i = 0;;) {
@@ -621,7 +618,7 @@ Components::~Components()
if (bExitWasCalled)
{
// do not write, re-join threads
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
if (writeThread_.is())
{
diff --git a/configmgr/source/components.hxx b/configmgr/source/components.hxx
index a44097810015..036ab702d394 100644
--- a/configmgr/source/components.hxx
+++ b/configmgr/source/components.hxx
@@ -158,7 +158,6 @@ private:
int userExtensionLayer_;
ModificationTarget modificationTarget_;
OUString modificationFileUrl_;
- std::shared_ptr<osl::Mutex> lock_;
};
}
diff --git a/configmgr/source/configurationprovider.cxx b/configmgr/source/configurationprovider.cxx
index f9936b6ba1a3..bc9615432224 100644
--- a/configmgr/source/configurationprovider.cxx
+++ b/configmgr/source/configurationprovider.cxx
@@ -85,8 +85,7 @@ class Service:
public:
explicit Service(
const css::uno::Reference< css::uno::XComponentContext >& context):
- ServiceBase(m_aMutex), context_(context), default_(true),
- lock_( lock() )
+ ServiceBase(m_aMutex), context_(context), default_(true)
{
assert(context.is());
}
@@ -95,8 +94,7 @@ public:
const css::uno::Reference< css::uno::XComponentContext >& context,
OUString const & locale):
ServiceBase(m_aMutex), context_(context), locale_(locale),
- default_(false),
- lock_( lock() )
+ default_(false)
{
assert(context.is());
}
@@ -163,7 +161,6 @@ private:
css::uno::Reference< css::uno::XComponentContext > context_;
OUString locale_;
bool default_;
- std::shared_ptr<osl::Mutex> lock_;
};
css::uno::Reference< css::uno::XInterface > Service::createInstance(
@@ -249,7 +246,7 @@ Service::createInstanceWithArguments(
" service " + ServiceSpecifier),
static_cast< cppu::OWeakObject * >(this));
}
- osl::MutexGuard guard(*lock_);
+ osl::MutexGuard guard(configmgr::GetLock());
Components & components = Components::getSingleton(context_);
rtl::Reference root(
new RootAccess(components, nodepath, locale, update));
@@ -317,12 +314,12 @@ void Service::removeFlushListener(
void Service::setLocale(css::lang::Locale const & eLocale)
{
- osl::MutexGuard guard(*lock_);
+ osl::MutexGuard guard(configmgr::GetLock());
locale_ = LanguageTag::convertToBcp47( eLocale, false);
}
css::lang::Locale Service::getLocale() {
- osl::MutexGuard guard(*lock_);
+ osl::MutexGuard guard(configmgr::GetLock());
css::lang::Locale loc;
if (! locale_.isEmpty()) {
loc = LanguageTag::convertToLocale( locale_, false);
@@ -333,7 +330,7 @@ css::lang::Locale Service::getLocale() {
void Service::flushModifications() const {
Components * components;
{
- osl::MutexGuard guard(*lock_);
+ osl::MutexGuard guard(configmgr::GetLock());
components = &Components::getSingleton(context_);
}
components->flushModifications();
diff --git a/configmgr/source/defaultprovider.cxx b/configmgr/source/defaultprovider.cxx
index 7161659e0fa6..fe79c174f654 100644
--- a/configmgr/source/defaultprovider.cxx
+++ b/configmgr/source/defaultprovider.cxx
@@ -33,7 +33,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
com_sun_star_comp_configuration_DefaultProvider_get_implementation(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
{
- osl::MutexGuard guard(*configmgr::lock());
+ osl::MutexGuard guard(configmgr::GetLock());
css::uno::Reference<css::uno::XInterface> singleton(
configmgr::configuration_provider::createDefault(context));
singleton->acquire();
diff --git a/configmgr/source/lock.cxx b/configmgr/source/lock.cxx
index 28220c15af89..33940fef91ed 100644
--- a/configmgr/source/lock.cxx
+++ b/configmgr/source/lock.cxx
@@ -25,9 +25,9 @@
namespace configmgr
{
-std::shared_ptr<osl::Mutex> const& lock()
+osl::Mutex& GetLock()
{
- static std::shared_ptr<osl::Mutex> theLock = std::make_shared<osl::Mutex>();
+ static osl::Mutex theLock;
return theLock;
}
}
diff --git a/configmgr/source/lock.hxx b/configmgr/source/lock.hxx
index 195dbf5e72c4..27353f8233a7 100644
--- a/configmgr/source/lock.hxx
+++ b/configmgr/source/lock.hxx
@@ -21,11 +21,10 @@
#include <sal/config.h>
#include <osl/mutex.hxx>
-#include <memory>
namespace configmgr
{
-std::shared_ptr<osl::Mutex> const& lock();
+osl::Mutex& GetLock();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/readonlyaccess.cxx b/configmgr/source/readonlyaccess.cxx
index 286963c783a2..76da9e5c71a9 100644
--- a/configmgr/source/readonlyaccess.cxx
+++ b/configmgr/source/readonlyaccess.cxx
@@ -92,7 +92,7 @@ void Service::initialize(css::uno::Sequence< css::uno::Any > const & aArguments)
throw css::uno::RuntimeException(
"already initialized", static_cast< cppu::OWeakObject * >(this));
}
- osl::MutexGuard g2(*lock());
+ osl::MutexGuard g2(configmgr::GetLock());
Components & components = Components::getSingleton(context_);
root_ = new RootAccess(components, "/", locale, false);
components.addRootAccess(root_);
diff --git a/configmgr/source/readwriteaccess.cxx b/configmgr/source/readwriteaccess.cxx
index 292124ddec25..fc231923588e 100644
--- a/configmgr/source/readwriteaccess.cxx
+++ b/configmgr/source/readwriteaccess.cxx
@@ -114,7 +114,7 @@ void Service::initialize(css::uno::Sequence< css::uno::Any > const & aArguments)
throw css::uno::RuntimeException(
"already initialized", static_cast< cppu::OWeakObject * >(this));
}
- osl::MutexGuard g2(*lock());
+ osl::MutexGuard g2(configmgr::GetLock());
Components & components = Components::getSingleton(context_);
root_ = new RootAccess(components, "/", locale, true);
components.addRootAccess(root_);
diff --git a/configmgr/source/rootaccess.cxx b/configmgr/source/rootaccess.cxx
index 17c8f7ec12a2..e24819ee8118 100644
--- a/configmgr/source/rootaccess.cxx
+++ b/configmgr/source/rootaccess.cxx
@@ -58,7 +58,6 @@ RootAccess::RootAccess(
OUString const & locale, bool update):
Access(components), pathRepresentation_(pathRepresentation),
locale_(locale),
- lock_( lock() ),
update_(update), finalized_(false), alive_(true)
{
}
@@ -113,7 +112,7 @@ void RootAccess::addChangesListener(
{
assert(thisIs(IS_ANY));
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
if (!aListener.is()) {
throw css::uno::RuntimeException(
@@ -134,7 +133,7 @@ void RootAccess::removeChangesListener(
css::uno::Reference< css::util::XChangesListener > const & aListener)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
ChangesListeners::iterator i(changesListeners_.find(aListener));
if (i != changesListeners_.end()) {
@@ -151,7 +150,7 @@ void RootAccess::commitChanges()
}
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
int finalizedLayer;
@@ -170,7 +169,7 @@ void RootAccess::commitChanges()
sal_Bool RootAccess::hasPendingChanges() {
assert(thisIs(IS_UPDATE));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
//TODO: Optimize:
std::vector< css::util::ElementChange > changes;
@@ -181,7 +180,7 @@ sal_Bool RootAccess::hasPendingChanges() {
css::uno::Sequence< ::css::util::ElementChange > RootAccess::getPendingChanges()
{
assert(thisIs(IS_UPDATE));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
std::vector< css::util::ElementChange > changes;
reportChildChanges(&changes);
@@ -190,7 +189,7 @@ css::uno::Sequence< ::css::util::ElementChange > RootAccess::getPendingChanges()
RootAccess::~RootAccess()
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
if (alive_)
getComponents().removeRootAccess(this);
}
@@ -281,7 +280,7 @@ void RootAccess::clearListeners() noexcept {
css::uno::Any RootAccess::queryInterface(css::uno::Type const & aType)
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
css::uno::Any res(Access::queryInterface(aType));
if (res.hasValue()) {
@@ -302,7 +301,7 @@ css::uno::Any RootAccess::queryInterface(css::uno::Type const & aType)
OUString RootAccess::getImplementationName()
{
assert(thisIs(IS_ANY));
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
checkLocalizedPropertyAccess();
return "configmgr.RootAccess";
}
diff --git a/configmgr/source/rootaccess.hxx b/configmgr/source/rootaccess.hxx
index 11fbea450eed..2e71d0943e7b 100644
--- a/configmgr/source/rootaccess.hxx
+++ b/configmgr/source/rootaccess.hxx
@@ -132,8 +132,6 @@ private:
OUString name_;
ChangesListeners changesListeners_;
- std::shared_ptr<osl::Mutex> lock_;
-
bool update_:1;
bool finalized_:1;
bool alive_:1;
diff --git a/configmgr/source/update.cxx b/configmgr/source/update.cxx
index 1cc2a06fe2a2..02b4dd5309fc 100644
--- a/configmgr/source/update.cxx
+++ b/configmgr/source/update.cxx
@@ -57,7 +57,6 @@ public:
context_(context)
{
assert(context.is());
- lock_ = lock();
}
private:
@@ -79,14 +78,13 @@ private:
css::uno::Sequence< OUString > const & includedPaths,
css::uno::Sequence< OUString > const & excludedPaths) override;
- std::shared_ptr<osl::Mutex> lock_;
css::uno::Reference< css::uno::XComponentContext > context_;
};
void Service::insertExtensionXcsFile(
sal_Bool shared, OUString const & fileUri)
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
Components::getSingleton(context_).insertExtensionXcsFile(shared, fileUri);
}
@@ -95,7 +93,7 @@ void Service::insertExtensionXcuFile(
{
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
Components & components = Components::getSingleton(context_);
Modifications mods;
components.insertExtensionXcuFile(shared, fileUri, &mods);
@@ -109,7 +107,7 @@ void Service::removeExtensionXcuFile(OUString const & fileUri)
{
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
Components & components = Components::getSingleton(context_);
Modifications mods;
components.removeExtensionXcuFile(fileUri, &mods);
@@ -126,7 +124,7 @@ void Service::insertModificationXcuFile(
{
Broadcaster bc;
{
- osl::MutexGuard g(*lock_);
+ osl::MutexGuard g(configmgr::GetLock());
Components & components = Components::getSingleton(context_);
Modifications mods;
components.insertModificationXcuFile(