peersim.core
Class Scheduler

java.lang.Object
  extended by peersim.core.Scheduler

public class Scheduler
extends java.lang.Object

A binary function over the time points. That is, for each time point returns a boolean value. The concept of time depends on the simulation model. Current time has to be set by the simulation engine, irrespective of the model, and can be read using CommonState.getTime(). This scheduler is interpreted over those time points.

In this simple implementation the valid times will be from, from+step, from+2*step, etc, where the last element is strictly less than until. Alternatively, if at is defined, then the schedule will be a single time point. If FINAL is defined, it is also added to the set of active time points. It refers to the time after the simulation has finished (see CommonState.getPhase()).


Parameter Summary
step
          Defaults to 1.
at
          Defaults to -1.
from
          Defaults to 0.
until
          Defaults to Long.MAX_VALUE.
FINAL
          Defines if component is active after the simulation has finished.
 
Field Summary
 boolean fin
           
 long from
           
protected  long next
          The next scheduled time point.
 long step
           
 long until
           
 
Constructor Summary
Scheduler(java.lang.String prefix)
          Reads configuration parameters from the component defined by prefix.
Scheduler(java.lang.String prefix, boolean useDefault)
          Reads configuration parameters from the component defined by prefix.
 
Method Summary
 boolean active()
          true if current time point is covered by this scheduler
 boolean active(long time)
          true if given time point is covered by this scheduler
 long getNext()
          Returns the next time point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Parameter Detail

step

Defaults to 1.


at

Defaults to -1. That is, defaults to be ineffective.


from

Defaults to 0.


until

Defaults to Long.MAX_VALUE.


FINAL

Defines if component is active after the simulation has finished. Note that the exact time the simulation finishes is not know in advance because other components can stop the simulation at any time. By default not set.

See Also:
CommonState.getPhase()
Field Detail

step

public final long step

from

public final long from

until

public final long until

fin

public final boolean fin

next

protected long next
The next scheduled time point.

Constructor Detail

Scheduler

public Scheduler(java.lang.String prefix)
Reads configuration parameters from the component defined by prefix. "step" defaults to 1.


Scheduler

public Scheduler(java.lang.String prefix,
                 boolean useDefault)
Reads configuration parameters from the component defined by prefix. If useDefault is false, then at least parameter "step" must be explicitly defined. Otherwise "step" defaults to 1.

Method Detail

active

public boolean active(long time)
true if given time point is covered by this scheduler


active

public boolean active()
true if current time point is covered by this scheduler


getNext

public long getNext()
Returns the next time point. If the returned value is negative, there are no more time points. As a side effect, it also updates the next time point, so repeated calls to this method return the scheduled times.