Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2014-03-27 15:30:20 -0400
committerJuergen Haug2014-03-27 18:17:23 -0400
commit742f7f882121c969b97f2108910b96ef0e4c5004 (patch)
tree6bc88a428b4fe25b95ec4ff13154e3c80b8a8542
parent76eed223d0f63f15d0e76e0759648e6906864fd8 (diff)
downloadorg.eclipse.etrice-742f7f882121c969b97f2108910b96ef0e4c5004.tar.gz
org.eclipse.etrice-742f7f882121c969b97f2108910b96ef0e4c5004.tar.xz
org.eclipse.etrice-742f7f882121c969b97f2108910b96ef0e4c5004.zip
bug 348173 - message services should be started according to thread prio
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeGen.java17
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageServiceController.java23
3 files changed, 35 insertions, 7 deletions
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeGen.xtend
index ff8b25407..1bfb41431 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeGen.xtend
@@ -216,7 +216,7 @@ class NodeGen {
static void «clsname»_startMessageServices(void) {
ET_MSC_LOGGER_SYNC_ENTRY("«clsname»", "startMessageServices")
- «FOR thread: threads»
+ «FOR thread: threads.sortBy[getPrio].reverse»
etMessageService_start(&msgService_«thread.name»);
«ENDFOR»
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeGen.java
index 51c571e6f..d0be36317 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/NodeGen.java
@@ -544,7 +544,14 @@ public class NodeGen {
_builder.append("\t");
_builder.newLine();
{
- for(final PhysicalThread thread_1 : threads) {
+ final Function1<PhysicalThread,Integer> _function_1 = new Function1<PhysicalThread,Integer>() {
+ public Integer apply(final PhysicalThread it) {
+ return Integer.valueOf(it.getPrio());
+ }
+ };
+ List<PhysicalThread> _sortBy = IterableExtensions.<PhysicalThread, Integer>sortBy(threads, _function_1);
+ List<PhysicalThread> _reverse = ListExtensions.<PhysicalThread>reverse(_sortBy);
+ for(final PhysicalThread thread_1 : _reverse) {
_builder.append("\t");
_builder.append("etMessageService_start(&msgService_");
String _name_11 = thread_1.getName();
@@ -828,12 +835,12 @@ public class NodeGen {
{
ActorClass _actorClass = ai.getActorClass();
EList<StandardOperation> _operations = _actorClass.getOperations();
- final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
+ final Function1<StandardOperation,Boolean> _function_2 = new Function1<StandardOperation,Boolean>() {
public Boolean apply(final StandardOperation op) {
return Boolean.valueOf(op.isDestructor());
}
};
- Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function_1);
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function_2);
boolean _isEmpty = IterableExtensions.isEmpty(_filter);
boolean _not = (!_isEmpty);
if (_not) {
@@ -915,12 +922,12 @@ public class NodeGen {
{
ActorClass _actorClass_3 = ai_1.getActorClass();
EList<StandardOperation> _operations_1 = _actorClass_3.getOperations();
- final Function1<StandardOperation,Boolean> _function_2 = new Function1<StandardOperation,Boolean>() {
+ final Function1<StandardOperation,Boolean> _function_3 = new Function1<StandardOperation,Boolean>() {
public Boolean apply(final StandardOperation op) {
return Boolean.valueOf(RoomHelpers.isConstructor(op));
}
};
- Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_2);
+ Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_3);
boolean _isEmpty_1 = IterableExtensions.isEmpty(_filter_1);
boolean _not_1 = (!_isEmpty_1);
if (_not_1) {
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageServiceController.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageServiceController.java
index 709cca82a..fd1089c79 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageServiceController.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageServiceController.java
@@ -12,8 +12,12 @@
package org.eclipse.etrice.runtime.java.messaging;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
/**
@@ -59,12 +63,29 @@ public class MessageServiceController {
}
public void start() {
+ Comparator<Thread> descendingPrioComparator = new Comparator<Thread>(){
+
+ @Override
+ public int compare(Thread o1, Thread o2) {
+ if(o1.getPriority() > o2.getPriority())
+ return -1;
+ if(o1.getPriority() < o2.getPriority())
+ return 1;
+ return 0;
+ }
+ };
+
// start all message services
+ List<Thread> threads = new ArrayList<Thread>(messageServices.size());
for (IMessageService msgSvc : messageServices.values()){
Thread thread = new Thread(msgSvc, msgSvc.getName());
msgSvc.setThread(thread);
+ threads.add(thread);
+ }
+
+ Collections.sort(threads, descendingPrioComparator);
+ for(Thread thread : threads){
thread.start();
- // TODOTS: start in order of priorities
}
running = true;
}

Back to the top