A manager for a single simulation case.
We view a simulation as a case or workflow of simulated tasks. This class is responsible for keeping track of all the tasks for the corresponding simulation, informing the Coordinator of new tasks to be added and informing the simulation processes when a task is completed.
=Basic Interaction Flow= The interaction flow with the Coordinator is expected as follows:
- The simulation logic starts executing via run.
- Tasks are added via task.
- When the simulation logic finishes producing tasks, it should call ready.
- Eventually, one of the tasks completes and complete is called. The simulation logic resumes execution.
- The simulation may now produce further tasks in reaction to the completed one(s). It can either handle and acknowledge each completed task individually using ack or use ready in one go as above.
- When the simulation logic completes, it can use succeed (instead of ack or ready) to notify the Coordinator of its result.
=Additional Functions= The simulation may also:
- React to things happening to other simulations. It can send a request to
wait
using simWait. The Coordinator will then wait for the Simulation to send new tasks or to complete, as if a task just completed. This needs to happen while the Coordinator is still waiting for the other simulation(s) we are reacting to. - Abort previously added tasks using abort.
- Report completion due to failure using fail.
- Optionally maintain a Lookahead structure of future tasks, returning it through getLookahead.
- Companion
- object
Document{}
Declare IDs of TaskInstances that need to be aborted.
Declare IDs of TaskInstances that need to be aborted.
- Value Params
- ids
The
UUID
s of the TaskInstances.
Declares that the simulation has finished processing one or more completed TaskInstances.
Declares that the simulation has finished processing one or more completed TaskInstances.
Identifies the tasks via their UUID.
Manages a completed TaskInstance.
Manages a completed TaskInstance.
The simulation logic must react to this by either registering more tasks or finishing.
If new tasks are produced, the completed TaskInstance must be acknowledged
via
ack. Alternatively, if we do not want to ack
all completed tasks, we can just call
ready. Finally, if the simulation completes, we can use done, succeed or fail
accordingly.
- Value Params
- task
The completed TaskInstance.
- time
The timestamp of completion and current time.
Declares that the simulation completed.
Declares that the simulation completed.
- Value Params
- result
The result of the simulation.
Declares that the simulation has failed or has been aborted.
Declares that the simulation has failed or has been aborted.
- Value Params
- exception
The
Throwable
that caused the failure.
Declares that the simulation has finished calculating and is ready for virtual time to proceed.
Declares that the simulation has finished calculating and is ready for virtual time to proceed.
Value members
Concrete methods
Inherited methods
A unique name for the simulation.
A unique name for the simulation.
- Returns
The name of the SimulationRef.
- Inherited from
- SimulationRef