Class SimulationEvent

java.lang.Object
org.bzdev.devqsim.SimulationEvent
All Implemented Interfaces:
Comparable<SimulationEvent>
Direct Known Subclasses:
TaskQueueSimEvent, TaskSimulationEvent

public abstract class SimulationEvent extends Object implements Comparable<SimulationEvent>
Superclass for simulation events. This class should be subclassed to create new types of simulation events - it is public to make it possible for an event to be canceled.
  • Constructor Details

    • SimulationEvent

      public SimulationEvent()
  • Method Details

    • getStackTraceArray

      protected StackTraceElement[] getStackTraceArray()
      Get the stack-trace array. When a simulation is in stack-trace mode, a stack trace is used to tag the point of time at which various events were created. In a few instances, a new event may be created with its stack trace being that of a preceding event.
      Returns:
      the stack-trace array; null if there is none
    • setStackTraceArray

      protected void setStackTraceArray(StackTraceElement[] array)
      Set the stack-trace array. When a simulation is in stack-trace mode, a stack trace is used to tag the point of time at which various events were created. In a few instances, a new event may be created with its stack trace being that of a preceding event.
      Parameters:
      array - the stack-trace array; null if not provided
    • getSource

      public Object getSource()
      Get the object labeled as the source of a simulation event. This object will either be the simulation itself or a SimObject that is responsible for creating the event.
      Returns:
      the source of the event
    • getTime

      public long getTime()
      get the time field
      Returns:
      the time in units of ticks
    • compareTo

      public final int compareTo(SimulationEvent event)
      Comparison method.
      Specified by:
      compareTo in interface Comparable<SimulationEvent>
      Parameters:
      event - another simulation event
      Returns:
      -1, 0, or 1 integer when this object is less than, equal to, or greater than the object denoted by event in terms of the time ordering of simulation events
    • cancel

      public boolean cancel()
      Cancel an event. The default behavior is to deschedule the event from the simulation's event queue. Subclasses should perform any additional processing and also call super.cancel() or deschedule the event explicitly.
      Returns:
      true if the event could be canceled; false otherwise
    • isCanceled

      public boolean isCanceled()
      Check if an event was canceled.
      Returns:
      true if the current event was canceled; false otherwise
    • isPending

      public boolean isPending()
      Determine if an event is pending. An event is pending if it has been scheduled on the event queue but not yet been processed. It is not pending while the event is being processed.
      Returns:
      true if this event is pending; false otherwise
    • processEvent

      protected abstract void processEvent()
      Process an event. This method will be invoked by the simulation scheduler when the event should occur. Subclasses must implement it if any processing is to occur.