Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2014-04-02 10:18:16 -0400
committerHenrik Rentz-Reichert2014-04-21 08:14:12 -0400
commite31180eb25056061186605db7542f3d1be3073f2 (patch)
treec775bddf46ab726bc663d2f302d655eb41fa03a1 /runtime/org.eclipse.etrice.runtime.java/src/org/eclipse
parent0d8e910f33c25bf0bcdf1c494d5af8aeb838facf (diff)
downloadorg.eclipse.etrice-e31180eb25056061186605db7542f3d1be3073f2.tar.gz
org.eclipse.etrice-e31180eb25056061186605db7542f3d1be3073f2.tar.xz
org.eclipse.etrice-e31180eb25056061186605db7542f3d1be3073f2.zip
[gen, runtime] java message service thread priority issue
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.java/src/org/eclipse')
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java
index 89379d42d..a160e66a9 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/MessageService.java
@@ -15,6 +15,7 @@ package org.eclipse.etrice.runtime.java.messaging;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
@@ -47,15 +48,18 @@ public class MessageService extends AbstractMessageService {
public MessageService(IRTObject parent, ExecMode mode, int nsec, int node, int thread, String name, int priority) {
super(parent, "MessageService_"+name, node, thread);
-
+
+ // Java thread priority is limited to 1-10 and cannot be changed
+ // thus priorities from physical mapping are not generated
+ // priority = Thread.NORM_PRIORITY generated fixed
this.priority = priority;
- assert priority >= Thread.MIN_PRIORITY : ("priority smaller than Thread.MIN_PRIORITY (1)");
- assert priority <= Thread.MAX_PRIORITY : ("priority bigger than Thread.MAX_PRIORITY (10)");
+ assert priority >= Thread.MIN_PRIORITY : ("priority smaller than Thread.MIN_PRIORITY (" + "Thread.MIN_PRIORITY" + ")");
+ assert priority <= Thread.MAX_PRIORITY : ("priority bigger than Thread.MAX_PRIORITY (" + "Thread.MAX_PRIORITY" + ")");
if(mode == ExecMode.MIXED || mode == ExecMode.POLLED){
pollingInterval = nsec;
- pollingScheduler = Executors.newScheduledThreadPool(1);
+ pollingScheduler = Executors.newScheduledThreadPool(1, new PollingThreadFactory());
assert pollingInterval > 0 : ("polling interval is 0 or negative");
}
@@ -189,5 +193,17 @@ public class MessageService extends AbstractMessageService {
}
}
+
+ private class PollingThreadFactory implements ThreadFactory{
+
+ @Override
+ public Thread newThread(Runnable arg0) {
+ Thread thread = new Thread(arg0, getName()+"_PollingThread");
+ thread.setPriority(priority);
+
+ return thread;
+ }
+
+ }
}

Back to the top