Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## avrora.sim.util
Class PeriodicEvent

    java.lang.Object
      avrora.sim.util.PeriodicEvent

All Implemented Interfaces:
  Simulator.Event

public class PeriodicEvent
extends java.lang.Object
implements Simulator.Event

The `PeriodicEvent` class is a utility that allows a `Simulator.Event` to be inserted into the simulator that will fire with a specified period of clock cycles. It works by automatically adding itself back into the timer queue at each firing.

See Also:
  `Simulator.Event`

Field Summary
`Simulator.Event` | `event` This field stores the event that will be fired after each period.
`long` | `period` This field stores the period (in clock cycles) that the event will be fired.
`Simulator` | `simulator` This field stores the simulator in which the event will continually be reinserted.

Constructor Summary
`PeriodicEvent(Simulator s, Simulator.Event t, long p)` The constructor for the `PeriodicEvent` class creates a new periodic event with the specified period.

Method Summary
`void` | `fire()` The `fire()` method is called by the simulator when the timer event occurs.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### simulator

    public final Simulator simulator

  This field stores the simulator in which the event will continually be reinserted.

### event

    public final Simulator.Event event

  This field stores the event that will be fired after each period.

### period

    public final long period

  This field stores the period (in clock cycles) that the event will be fired.

Constructor Detail

### PeriodicEvent

    public PeriodicEvent(Simulator s,
                         Simulator.Event t,
                         long p)

  The constructor for the `PeriodicEvent` class creates a new periodic event with the specified period. Each time the event fires, it will be added again back into the simulator's timer event queue with the same delta. The result is the specified event fires with the precise period specified.

  Creating the `PeriodicEvent` does not insert it into the simulator. It is important that these instances of `Simulator` match--this probe will always reinsert itself into the instance passed in the constructor.

Parameters:
  `s` - the simulator in which to reinsert the event each time
  `t` - the event to fire after each period
  `p` - the period in clock cycles

Method Detail

### fire

    public void fire()

  The `fire()` method is called by the simulator when the timer event occurs. In this implementation, the periodic event is reinserted into the timer queue, and then the `fire()` method of the event is called.

  Specified by:
    `fire` in interface `Simulator.Event`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD