This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/add_build_to_svc_dep_creation in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/feature/add_build_to_svc_dep_creation by this push: new 5937f9c Removes lock from dep man. The dependency manager is not designed for MT. 5937f9c is described below commit 5937f9c6c088d57783e23eb32b6dd8a0dd24860c Author: Pepijn Noltes <pepijnnol...@gmail.com> AuthorDate: Wed Nov 11 21:28:08 2020 +0100 Removes lock from dep man. The dependency manager is not designed for MT. --- libs/framework/include/celix/dm/DependencyManager.h | 5 +++-- libs/framework/include/celix/dm/DependencyManager_Impl.h | 15 ++------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/libs/framework/include/celix/dm/DependencyManager.h b/libs/framework/include/celix/dm/DependencyManager.h index 36152c2..b63b46a 100644 --- a/libs/framework/include/celix/dm/DependencyManager.h +++ b/libs/framework/include/celix/dm/DependencyManager.h @@ -32,6 +32,9 @@ namespace celix { namespace dm { + /** + * The Dependency Manager, Component, ServiceDependency and Properties are not thread safe! + */ class DependencyManager { public: DependencyManager(celix_bundle_context_t *ctx); @@ -127,8 +130,6 @@ namespace celix { namespace dm { private: const std::shared_ptr<celix_bundle_context_t> context; const std::shared_ptr<celix_dependency_manager_t> cDepMan; - //TODO TBD, The Dependency Manager (and underlining classes are not designed for thread safety.. so can this mutex be removed? - std::recursive_mutex componentsMutex{}; std::vector<std::shared_ptr<BaseComponent>> components {}; }; diff --git a/libs/framework/include/celix/dm/DependencyManager_Impl.h b/libs/framework/include/celix/dm/DependencyManager_Impl.h index 91f5c2c..08fe981 100644 --- a/libs/framework/include/celix/dm/DependencyManager_Impl.h +++ b/libs/framework/include/celix/dm/DependencyManager_Impl.h @@ -33,7 +33,6 @@ inline Component<T>& DependencyManager::createComponent(std::string name) { Component<T>::create(this->context.get(), this->cDepMan.get()) : Component<T>::create(this->context.get(), this->cDepMan.get(), name); if (cmp->isValid()) { - std::lock_guard<std::recursive_mutex> lock(componentsMutex); this->components.push_back(std::unique_ptr<BaseComponent> {cmp}); } return *cmp; @@ -59,14 +58,7 @@ inline void DependencyManager::start() { } inline void DependencyManager::build() { - std::vector<std::shared_ptr<BaseComponent>> toBeStartedComponents {}; - { - std::lock_guard<std::recursive_mutex> lock(componentsMutex); - for (auto& cmp : components) { - toBeStartedComponents.push_back(cmp); - } - } - for (auto& cmp : toBeStartedComponents) { + for (auto& cmp : components) { cmp->runBuild(); } } @@ -78,10 +70,7 @@ inline void DependencyManager::destroyComponent(Component<T> &component) { inline void DependencyManager::clear() { celix_dependencyManager_removeAllComponents(cDepMan.get()); - { - std::lock_guard<std::recursive_mutex> lock(componentsMutex); - components.clear(); - } + components.clear(); } inline void DependencyManager::stop() {