celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [celix] pnoltes commented on a change in pull request #313: Feature/refactor c dep man service trackers
Date Tue, 02 Feb 2021 13:39:43 GMT

pnoltes commented on a change in pull request #313:
URL: https://github.com/apache/celix/pull/313#discussion_r568607313



##########
File path: libs/framework/src/dm_component_impl.c
##########
@@ -282,78 +304,72 @@ celix_status_t component_removeServiceDependency(celix_dm_component_t
*component
     return celix_dmComponent_removeServiceDependency(component, dependency);
 }
 
-celix_status_t celix_dmComponent_removeServiceDependency(celix_dm_component_t *component,
celix_dm_service_dependency_t *dependency) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    executor_executeTask(component->executor, component, component_removeTask, dependency);
-
-    return status;
-}
-
-static celix_status_t component_removeTask(celix_dm_component_t *component, celix_dm_service_dependency_t
*dependency) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    arrayList_removeElement(component->dependencies, dependency);
-    pthread_mutex_unlock(&component->mutex);
-
-    if (component->state != DM_CMP_STATE_INACTIVE) {
-        serviceDependency_stop(dependency);
+celix_status_t celix_private_dmComponent_enable(celix_dm_component_t *component) {
+    celixThreadMutex_lock(&component->mutex);
+    if (!component->isEnabled) {
+        component->isEnabled = true;
     }
+    celixThreadMutex_unlock(&component->mutex);
+    celix_dmComponent_handleChange(component);

Review comment:
       not really needed, handle change will do (effectually) nothing. But it does generate
unneeded events. So I updated this.

##########
File path: libs/framework/src/dm_component_impl.c
##########
@@ -282,78 +304,72 @@ celix_status_t component_removeServiceDependency(celix_dm_component_t
*component
     return celix_dmComponent_removeServiceDependency(component, dependency);
 }
 
-celix_status_t celix_dmComponent_removeServiceDependency(celix_dm_component_t *component,
celix_dm_service_dependency_t *dependency) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    executor_executeTask(component->executor, component, component_removeTask, dependency);
-
-    return status;
-}
-
-static celix_status_t component_removeTask(celix_dm_component_t *component, celix_dm_service_dependency_t
*dependency) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    arrayList_removeElement(component->dependencies, dependency);
-    pthread_mutex_unlock(&component->mutex);
-
-    if (component->state != DM_CMP_STATE_INACTIVE) {
-        serviceDependency_stop(dependency);
+celix_status_t celix_private_dmComponent_enable(celix_dm_component_t *component) {
+    celixThreadMutex_lock(&component->mutex);
+    if (!component->isEnabled) {
+        component->isEnabled = true;
     }
+    celixThreadMutex_unlock(&component->mutex);
+    celix_dmComponent_handleChange(component);
+    return CELIX_SUCCESS;
+}
 
-    pthread_mutex_lock(&component->mutex);
-    array_list_pt events = hashMap_remove(component->dependencyEvents, dependency);
-    pthread_mutex_unlock(&component->mutex);
-
-	serviceDependency_destroy(&dependency);
-
-    while (!arrayList_isEmpty(events)) {
-    	dm_event_pt event = arrayList_remove(events, 0);
-    	event_destroy(&event);
+static celix_status_t celix_dmComponent_disable(celix_dm_component_t *component) {
+    celixThreadMutex_lock(&component->mutex);
+    if (component->isEnabled) {
+        component->isEnabled = false;
     }
-    arrayList_destroy(events);
-
-    component_handleChange(component);
-
-    return status;
+    celixThreadMutex_unlock(&component->mutex);
+    celix_dmComponent_handleChange(component);

Review comment:
       same




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message