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:
@@ -22,6 +22,8 @@ package com.samskivert.util;
|
|||||||
|
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for a service that queues up execution of Runnables.
|
* 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.
|
* Post the specified Runnable to be run on the RunQueue.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -100,13 +100,9 @@ public class SerialExecutor
|
|||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public SerialExecutor (final RunQueue receiver)
|
public SerialExecutor (RunQueue receiver)
|
||||||
{
|
{
|
||||||
this(new Executor() {
|
this(new RunQueue.AsExecutor(receiver));
|
||||||
public void execute (Runnable r) {
|
|
||||||
receiver.postRunnable(r);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// from Executor
|
// from Executor
|
||||||
|
|||||||
Reference in New Issue
Block a user