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.clock
Class SystemClock

    java.lang.Object
      avrora.sim.clock.Clock
          avrora.sim.clock.SystemClock

public class SystemClock
extends Clock

The `SystemClock` class represents a wrapper around the system clock that measures actual wall clock time passed in simulation. This implementation encapsulates the `System.currentTimeMillis()` method, and thus provides a precision of approximately 1000 cycles per second.

Field Summary

Fields inherited from class avrora.sim.clock.Clock
`hz, name`

Method Summary
`static SystemClock` | `get()` The `get()` method retrieves the singleton instance of the system clock.
`long` | `getCount()` The `getCount()` method returns the number of clock cycles (ticks) that have elapsed for this clock.
`long` | `getFirstEventDelta()` The `getFirstEventDelta()` method returns the number of clock cycles until the first event in the event queue will fire.
`void` | `insertEvent(Simulator.Event e, long cycles)` The `insertEvent()` method inserts an event into the event queue of the clock with the specified delay in clock cycles.
`void` | `removeEvent(Simulator.Event e)` The `removeEvent()` method removes an event from the event queue of the clock.

Methods inherited from class avrora.sim.clock.Clock
`getHZ, getName`

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

Method Detail

### get

    public static SystemClock get()

  The `get()` method retrieves the singleton instance of the system clock.

  Returns:
    an instance of the `SystemClock` class

### getCount

    public long getCount()

  The `getCount()` method returns the number of clock cycles (ticks) that have elapsed for this clock.

  Specified by:
    `getCount` in class `Clock`
  Returns:
    the number of elapsed time ticks in clock cycles

### insertEvent

    public void insertEvent(Simulator.Event e,
                            long cycles)

  The `insertEvent()` method inserts an event into the event queue of the clock with the specified delay in clock cycles. The event will then be executed at the future time specified.

  Specified by:
    `insertEvent` in class `Clock`
  Parameters:
    `e` - the event to be inserted
    `cycles` - the number of cycles in the future at which to fire

### removeEvent

    public void removeEvent(Simulator.Event e)

  The `removeEvent()` method removes an event from the event queue of the clock. The comparison used is reference equality, not `.equals()`.

  Specified by:
    `removeEvent` in class `Clock`
  Parameters:
    `e` - the event to remove

### getFirstEventDelta

    public long getFirstEventDelta()

  The `getFirstEventDelta()` method returns the number of clock cycles until the first event in the event queue will fire. This method will return -1 if there are no events in the queue.

  Returns:
    the delta in clock cycles of the first event in the queue; -1 if there are no events in the queue

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