Package com.amalgamasimulation.engine
Class Event
java.lang.Object
com.amalgamasimulation.engine.Event
- Direct Known Subclasses:
StopEvent
,TraceableEvent
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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected long
protected Runnable
protected double
protected int
protected Event.Status
protected double
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
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 scheduledint
sequence()
Returns the sequence number that determines the order of execution of events scheduled for the same time.status()
Returns the current status of this eventdouble
time()
Returns the simulation time at which this event is scheduled for executiontoString()
-
Field Details
-
scheduledTime
protected double scheduledTime -
time
protected double time -
sequence
protected int sequence -
status
-
id
protected long id -
runnable
-
-
Method Details
-
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 eachEngine
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 inEvent.Status.SCHEDULED
state). Does nothing otherwise. Note that there is no way to undo canceling of the event -
toString
-