java.lang.Object
org.bzdev.devqsim.SimulationEvent
- All Implemented Interfaces:
Comparable<SimulationEvent>
- Direct Known Subclasses:
TaskQueueSimEvent
,TaskSimulationEvent
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel()
Cancel an event.final int
compareTo
(SimulationEvent event) Comparison method.Get the object labeled as the source of a simulation event.protected StackTraceElement[]
Get the stack-trace array.long
getTime()
get the time fieldboolean
Check if an event was canceled.boolean
Determine if an event is pending.protected abstract void
Process an event.protected void
setStackTraceArray
(StackTraceElement[] array) Set the stack-trace array.
-
Constructor Details
-
SimulationEvent
public SimulationEvent()
-
-
Method Details
-
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
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
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
Comparison method.- Specified by:
compareTo
in interfaceComparable<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.
-