Constructor and Description |
---|
TickerBehavior(long millis)
Creates a behavior that is executed every specified period.
|
TickerBehavior(long millis,
java.lang.Runnable runnable)
Creates a behavior that is executed every specified period.
|
Modifier and Type | Method and Description |
---|---|
void |
action()
This method calls
onTick() once every specified period. |
static TickerBehavior |
create(long millis,
java.lang.Runnable runnable)
Creates a new TickerBehavior which runs the specified Runnable every specified period.
|
boolean |
done()
Returns true once
stop() is called, false otherwise. |
int |
getPriority()
This method should return a number that denotes the priority of a behavior.
|
int |
getTickCount()
Returns the number of times the
onTick() method of this behavior
has been called (including any ongoing call). |
void |
onStart()
Computes the wakeup time for the first execution of this behavior.
|
void |
onTick()
This method is called once every specified period.
|
void |
reset()
Resets the behavior, allowing it to be used again.
|
void |
stop()
Terminates the behavior.
|
agent, agentForService, agentForService, agentsForService, agentsForService, block, block, compareTo, isBlocked, onEnd, println, restart
public TickerBehavior(long millis)
millis
- period in milliseconds.public TickerBehavior(long millis, java.lang.Runnable runnable)
millis
- period in milliseconds.runnable
- Runnable to run.public final void stop()
public final int getTickCount()
onTick()
method of this behavior
has been called (including any ongoing call).onTick()
method has been called.public void onTick()
public void onStart()
onStart
in class Behavior
Behavior.onStart()
public final void action()
onTick()
once every specified period.action
in class Behavior
Behavior.action()
public final boolean done()
stop()
is called, false otherwise.done
in class Behavior
stop()
is called, false otherwise.Behavior.done()
public void reset()
reset
in class Behavior
Behavior.reset()
public int getPriority()
Behavior
getPriority
in class Behavior
public static TickerBehavior create(long millis, java.lang.Runnable runnable)
millis
- Period in milliseconds.runnable
- Runnable to run.