Class Event

java.lang.Object
com.amalgamasimulation.engine.Event
Direct Known Subclasses:
StopEvent, TraceableEvent

public class Event extends Object
Class representing one simulation event executed inside an Engine. The event is defined by:
  • simulation time - the simulation time at which it is scheduled for execution
  • sequence number - an integer number defining the order of execution for the events scheduled for the same time
  • action - an action (typically, a lambda or method reference) that will be executed by the engine at the designated simulation time
Author:
Andrey Malykhanov
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Possible statuses of Event.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected long
     
    protected Runnable
     
    protected double
     
    protected int
     
    protected Event.Status
     
    protected double
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Cancels the scheduled execution of this event if it has not yet started its execution (i.e.
    long
    id()
    Returns the identifier of this event.
    double
    Returns the simulation time when this event was created and scheduled
    int
    Returns the sequence number that determines the order of execution of events scheduled for the same time.
    Returns the current status of this event
    double
    Returns the simulation time at which this event is scheduled for execution
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • scheduledTime

      protected double scheduledTime
    • time

      protected double time
    • sequence

      protected int sequence
    • status

      protected Event.Status status
    • id

      protected long id
    • runnable

      protected Runnable runnable
  • Method Details

    • status

      public Event.Status status()
      Returns the current status of this event
      Returns:
      current status of this event
    • scheduledTime

      public double scheduledTime()
      Returns the simulation time when this event was created and scheduled
      Returns:
      simulation time when this event was created and scheduled
    • time

      public double time()
      Returns the simulation time at which this event is scheduled for execution
      Returns:
      simulation time at which this event is scheduled for execution
    • id

      public long id()
      Returns the identifier of this event. All events have unique incremental identifiers within each Engine run
      Returns:
      identifier of this event
    • sequence

      public int sequence()
      Returns the sequence number that determines the order of execution of events scheduled for the same time. The events are executed in ascending order of their sequence numbers. There is no guarantee about the execution order of event scheduled for the same time with same sequence numbers
      Returns:
      sequence number of this event
    • cancel

      public void cancel()
      Cancels the scheduled execution of this event if it has not yet started its execution (i.e. this event is in Event.Status.SCHEDULED state). Does nothing otherwise. Note that there is no way to undo canceling of the event
    • toString

      public String toString()
      Overrides:
      toString in class Object