You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2018/12/06 17:14:18 UTC
celix git commit: CELIX-438: Fixes an issue in the dm component with
task handling
Repository: celix
Updated Branches:
refs/heads/develop dcd5bdafe -> 009fd056e
CELIX-438: Fixes an issue in the dm component with task handling
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/009fd056
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/009fd056
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/009fd056
Branch: refs/heads/develop
Commit: 009fd056ece135d0c2ded4d042e032167f4d5ba5
Parents: dcd5bda
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Thu Dec 6 18:13:39 2018 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Thu Dec 6 18:13:39 2018 +0100
----------------------------------------------------------------------
libs/framework/src/dm_component_impl.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/009fd056/libs/framework/src/dm_component_impl.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/dm_component_impl.c b/libs/framework/src/dm_component_impl.c
index 0b82c3f..c2cc825 100644
--- a/libs/framework/src/dm_component_impl.c
+++ b/libs/framework/src/dm_component_impl.c
@@ -1417,21 +1417,26 @@ static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t curre
dm_executor_task_t *entry = NULL;
pthread_mutex_lock(&executor->mutex);
- int size = celix_arrayList_size(executor->workQueue);
- celix_array_list_t *localQueue = celix_arrayList_create(); //TODO add reserve or create with cap
- for (int i = 0; i < size; ++i) {
- celix_arrayList_add(localQueue, celix_arrayList_get(executor->workQueue, i));
+ if (celix_arrayList_size(executor->workQueue) > 0) {
+ entry = celix_arrayList_get(executor->workQueue, 0);
+ celix_arrayList_removeAt(executor->workQueue, 0);
}
- celix_arrayList_clear(executor->workQueue);
pthread_mutex_unlock(&executor->mutex);
- size = celix_arrayList_size(localQueue);
- for (int i = 0; i < size; ++i) {
- entry = celix_arrayList_get(localQueue, i);
- entry->command(entry->component, entry->data);
- free(entry);
+ while (entry != NULL) {
+ entry->command(entry->component, entry->data);
+ free(entry);
+
+ pthread_mutex_lock(&executor->mutex);
+ if (celix_arrayList_size(executor->workQueue) > 0) {
+ entry = celix_arrayList_get(executor->workQueue, 0);
+ celix_arrayList_removeAt(executor->workQueue, 0);
+ } else {
+ entry = NULL;
+ }
+ pthread_mutex_unlock(&executor->mutex);
}
- celix_arrayList_destroy(localQueue);
+
pthread_mutex_lock(&executor->mutex);
executor->runningThreadSet = false;