diff options
author | Sven Gothel <[email protected]> | 2011-10-15 07:24:02 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-10-15 07:24:02 +0200 |
commit | 76145eca17724f86e6a16e20b4b6e7ca5d39da34 (patch) | |
tree | 58224794487f3d1c52e4941ac2dc6c1f56cdab5d /src | |
parent | ea3486fd2a98ca00c62b9f0b7e3ef8251387f971 (diff) |
NEWT/EDTUtil: Allow get/set poll period, defaults to defaultEDTPollPeriod
Diffstat (limited to 'src')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/util/EDTUtil.java | 12 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 11 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 14 |
3 files changed, 32 insertions, 5 deletions
diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index d1a11a788..4493e2781 100644 --- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -49,9 +49,19 @@ package com.jogamp.newt.util; */ public interface EDTUtil { - public static final long defaultEDTPollGranularity = 10; // 10ms, 1/100s + public static final long defaultEDTPollPeriod = 10; // 10ms, 1/100s /** + * @return poll period in milliseconds + */ + public long getPollPeriod(); + + /** + * @param ms poll period in milliseconds + */ + public void setPollPeriod(long ms); + + /** * Create a new EDT. One should invoke <code>reset()</code><br> * after <code>invokeStop(..)</code> in case another <code>start()</code> or <code>invoke(..)</code> * is expected. diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index 0bcd3323c..fd757fba6 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -55,6 +55,7 @@ public class DefaultEDTUtil implements EDTUtil { private String name; int start_iter=0; private Runnable dispatchMessages; + private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; public DefaultEDTUtil(ThreadGroup tg, String name, Runnable dispatchMessages) { this.threadGroup = tg; @@ -64,6 +65,14 @@ public class DefaultEDTUtil implements EDTUtil { this.edt.setDaemon(true); // don't stop JVM from shutdown .. } + final public long getPollPeriod() { + return pollPeriod; + } + + final public void setPollPeriod(long ms) { + pollPeriod = ms; + } + public final void reset() { synchronized(edtLock) { waitUntilStopped(); @@ -271,7 +280,7 @@ public class DefaultEDTUtil implements EDTUtil { // wait for tasks if(!shouldStop && tasks.size()==0) { try { - tasks.wait(defaultEDTPollGranularity); + tasks.wait(pollPeriod); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index cca1e321c..6d0b102c7 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -29,7 +29,6 @@ package jogamp.newt.driver.awt; import java.awt.EventQueue; -import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -49,7 +48,8 @@ public class AWTEDTUtil implements EDTUtil { private static TimerTask pumpMessagesTimerTask=null; private static final Map<Display, Runnable> pumpMessageDisplayMap = new HashMap<Display, Runnable>(); private static AWTEDTUtil singletonMainThread = new AWTEDTUtil(); // one singleton MainThread - + private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; + public static AWTEDTUtil getSingleton() { return singletonMainThread; } @@ -58,6 +58,14 @@ public class AWTEDTUtil implements EDTUtil { // package private access .. } + final public long getPollPeriod() { + return pollPeriod; + } + + final public void setPollPeriod(long ms) { + pollPeriod = ms; + } + final public void reset() { // nop AWT is always running } @@ -132,7 +140,7 @@ public class AWTEDTUtil implements EDTUtil { } } }; - pumpMessagesTimer.scheduleAtFixedRate(pumpMessagesTimerTask, 0, defaultEDTPollGranularity); + pumpMessagesTimer.scheduleAtFixedRate(pumpMessagesTimerTask, 0, pollPeriod); } pumpMessageDisplayMap.put(dpy, pumpMessage); } |