Added an Executor adapter class to RunQueue...

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2672 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray.j.greenwell
2009-12-08 19:02:32 +00:00
parent 7fb3c3354c
commit 44c1d15c4b
2 changed files with 25 additions and 6 deletions
@@ -22,6 +22,8 @@ package com.samskivert.util;
import java.awt.EventQueue;
import java.util.concurrent.Executor;
/**
* An interface for a service that queues up execution of Runnables.
*/
@@ -40,6 +42,27 @@ public interface RunQueue
}
};
/**
* Wee helper class to adapt a RunQueue into an Executor.
* While we transition from RunQueue to Executor.
*/
public static class AsExecutor
implements Executor
{
public AsExecutor (RunQueue toAdapt)
{
_runQueue = toAdapt;
}
// from Executor
public void execute (Runnable command)
{
_runQueue.postRunnable(command);
}
protected RunQueue _runQueue;
}
/**
* Post the specified Runnable to be run on the RunQueue.
*/
@@ -100,13 +100,9 @@ public class SerialExecutor
* @deprecated
*/
@Deprecated
public SerialExecutor (final RunQueue receiver)
public SerialExecutor (RunQueue receiver)
{
this(new Executor() {
public void execute (Runnable r) {
receiver.postRunnable(r);
}
});
this(new RunQueue.AsExecutor(receiver));
}
// from Executor