Class AbstractSimEvent<T extends Number & Comparable<T>>

java.lang.Object
nl.tudelft.simulation.dsol.formalisms.eventscheduling.AbstractSimEvent<T>
Type Parameters:
T - the type of simulation time, e.g. Double, Long or Duration
All Implemented Interfaces:
Serializable, Comparable<SimEventInterface<T>>, SimEventInterface<T>
Direct Known Subclasses:
LambdaSimEvent, SimEvent

public abstract class AbstractSimEvent<T extends Number & Comparable<T>> extends Object implements SimEventInterface<T>, Serializable
The AbstractSimEvent forms the basement for SimEvents and defines a compare method by which eventLists can compare priority of the event.

Copyright (c) 2002-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.

Since:
1.5
Author:
Peter Jacobs
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected T
    absoluteExecutionTime reflects the time at which the event is scheduled.
    protected long
    the id used in compare statements.
    protected short
    priority reflects the priority of the event.

    Fields inherited from interface nl.tudelft.simulation.dsol.formalisms.eventscheduling.SimEventInterface

    MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractSimEvent(T executionTime)
    The constructor of the event stores the time the event must be executed and the object and method to invoke.
    AbstractSimEvent(T executionTime, short priority)
    The constructor of the event stores the time the event must be executed and the object and method to invoke.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Executes the simEvent.
    Return the scheduled absolute execution time of a simulation event.
    long
    Return the event's id to act as a tie breaker when both the time and the priority are equal.
    short
    Return the priority of the event to act as a tie breaker when two events are scheduled at the same time.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface nl.tudelft.simulation.dsol.formalisms.eventscheduling.SimEventInterface

    compareTo
  • Field Details

    • absoluteExecutionTime

      protected T extends Number & Comparable<T> absoluteExecutionTime
      absoluteExecutionTime reflects the time at which the event is scheduled.
    • priority

      protected short priority
      priority reflects the priority of the event.
    • id

      protected long id
      the id used in compare statements.
  • Constructor Details

    • AbstractSimEvent

      public AbstractSimEvent(T executionTime)
      The constructor of the event stores the time the event must be executed and the object and method to invoke.
      Parameters:
      executionTime - T; reflects the time the event has to be executed.
    • AbstractSimEvent

      public AbstractSimEvent(T executionTime, short priority)
      The constructor of the event stores the time the event must be executed and the object and method to invoke.
      Parameters:
      executionTime - T; reflects the time the event has to be executed.
      priority - short; reflects the priority of the event
  • Method Details

    • execute

      public abstract void execute() throws SimRuntimeException
      Executes the simEvent.
      Specified by:
      execute in interface SimEventInterface<T extends Number & Comparable<T>>
      Throws:
      SimRuntimeException - on execution failure
    • getAbsoluteExecutionTime

      public T getAbsoluteExecutionTime()
      Return the scheduled absolute execution time of a simulation event.
      Specified by:
      getAbsoluteExecutionTime in interface SimEventInterface<T extends Number & Comparable<T>>
      Returns:
      T; the scheduled absolute execution time of a simulation event
    • getPriority

      public short getPriority()
      Return the priority of the event to act as a tie breaker when two events are scheduled at the same time.
      Specified by:
      getPriority in interface SimEventInterface<T extends Number & Comparable<T>>
      Returns:
      The priority of a simulation event. The priorities are programmed according to the Java thread priority. Use 10 (MAX_PRIORITY), 9, .. , 5 (NORMAL_PRIORITY), 1 (MIN_PRIORITY)
    • getId

      public long getId()
      Return the event's id to act as a tie breaker when both the time and the priority are equal. Typically, the id is implemented as an incremental counter.
      Specified by:
      getId in interface SimEventInterface<T extends Number & Comparable<T>>
      Returns:
      long; the event's id to act as a tie breaker when both the time and the priority are equal