Added Factory interface here. I will remove it from Narya shortly.

This commit is contained in:
Michael Bayne
2011-04-27 07:53:33 -07:00
parent 5a9665f803
commit d79cb9aa0e
@@ -18,6 +18,23 @@ import static com.samskivert.Log.log;
*/ */
public abstract class Interval public abstract class Interval
{ {
/**
* An interface for entities that create, and keep track of, intervals. The intended use case
* is for repeating intervals to be created via a factory that tracks all such intervals, and
* which automatically cancels still running intervals when the factory is shut down.
*/
public interface Factory
{
/**
* Creates an {@link Interval} that runs the supplied runnable. For example:
* <pre>
* _factory.newInterval(someRunnable).schedule(500); // one shot
* Interval ival = _factory.newInterval(someRunnable).schedule(500, true); // repeater
* </pre>
*/
Interval newInterval (Runnable action);
}
/** /**
* An interface that will be implemented by the runnable posted to a RunQueue that can be used * An interface that will be implemented by the runnable posted to a RunQueue that can be used
* to retrieve the original Interval. * to retrieve the original Interval.
@@ -46,7 +63,6 @@ public abstract class Interval
@Override public void expired () { @Override public void expired () {
onExpired.run(); onExpired.run();
} }
@Override public String toString () { @Override public String toString () {
return onExpired.toString(); return onExpired.toString();
} }
@@ -66,7 +82,6 @@ public abstract class Interval
@Override public void expired () { @Override public void expired () {
onExpired.run(); onExpired.run();
} }
@Override public String toString () { @Override public String toString () {
return onExpired.toString(); return onExpired.toString();
} }