Create a special Runnable for posting to the RunQueue, rather than checking
to see if we're on the RunQueue twice each firing. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1560 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -118,6 +118,7 @@ public abstract class Interval
|
|||||||
// only expire the interval if the task is still valid
|
// only expire the interval if the task is still valid
|
||||||
if (_task == task) {
|
if (_task == task) {
|
||||||
try {
|
try {
|
||||||
|
System.err.println("Expiring Interval");
|
||||||
expired();
|
expired();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.warning("Interval broken in expired(): " + t);
|
Log.warning("Interval broken in expired(): " + t);
|
||||||
@@ -131,14 +132,27 @@ public abstract class Interval
|
|||||||
*/
|
*/
|
||||||
protected class IntervalTask extends TimerTask
|
protected class IntervalTask extends TimerTask
|
||||||
{
|
{
|
||||||
// documentation inherited
|
{ // initializer
|
||||||
public void run () {
|
if (_runQueue != null) {
|
||||||
if (_runQueue == null || _runQueue.isDispatchThread()) {
|
_runner = new Runnable() {
|
||||||
safelyExpire(this);
|
public void run () {
|
||||||
} else {
|
safelyExpire(IntervalTask.this);
|
||||||
_runQueue.postRunnable(this);
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public void run () {
|
||||||
|
if (_runQueue == null) {
|
||||||
|
safelyExpire(this);
|
||||||
|
} else {
|
||||||
|
_runQueue.postRunnable(_runner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** If we are using a RunQueue, the Runnable we post to it. */
|
||||||
|
protected Runnable _runner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** If non-null, the RunQueue used to run the expired() method for each
|
/** If non-null, the RunQueue used to run the expired() method for each
|
||||||
|
|||||||
Reference in New Issue
Block a user