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 /runtime/org.eclipse.etrice.runtime.java/src
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
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.java/src')
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageServiceController.java23
1 files changed, 22 insertions, 1 deletions
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