T - Actor type.public class DefaultActionScheduler<T> extends java.lang.Object implements ActionScheduler<T>
ActionScheduler implementation that schedules all actions against the supplied actor.
Weak references are kept against all scheduled tasks so they can be bulk cancelled (these are
also cleared on ActionEngine change).ActionEngine is supplied ForkJoinActionEngine.commonPoolEngine()
will be used.| Constructor and Description |
|---|
DefaultActionScheduler(T actor)
Creates a DefaultScheduler for the supplied actor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancelAllScheduledForActor()
Cancel all tasks scheduled to the current engine for the actor by this scheduler.
|
T |
getActor()
Gets the action Actor.
|
ActionEngine |
getEngine()
Gets the associated engine.
|
SchedulableActionContext<T> |
newContextForActor(Action<T> action)
Creates a new mutable context for the supplied action and this actor.
|
ActionContext<T> |
scheduleForActor(Action<T> action,
long initialDelay,
long period,
java.util.concurrent.TimeUnit unit)
Schedules an action for execution with a supplied initial delay and repeat period.
|
void |
setEngine(ActionEngine engine)
Associates a engine to this scheduler (if the engine changes all task references are lost).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitscheduleForActor, scheduleForActorpublic DefaultActionScheduler(T actor)
actor - Actor to schedule actions against.public void cancelAllScheduledForActor()
cancelAllScheduledForActor in interface ActionScheduler<T>public T getActor()
public ActionEngine getEngine()
public SchedulableActionContext<T> newContextForActor(Action<T> action)
ActionSchedulernewContextForActor in interface ActionScheduler<T>action - Action to create context for.public ActionContext<T> scheduleForActor(Action<T> action, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
ActionSchedulerscheduleForActor in interface ActionScheduler<T>action - Action to schedule.initialDelay - Initial delay before schedule (can be 0).period - Period for repeating (can be 0).unit - Time unit of initial delay and period.public void setEngine(ActionEngine engine)
engine - Engine to schedule actions against.