Thread Control Strategy

This module contains the definition of a simulation control strategy. It has the definition of the ThreadControlStrategy, that allows control simulations using the library threading.

Example

Using the strategy:

...
dynamic_system = some_discrete_event_dynamic_system
simulator = DiscreteEventSimulationEngine(dynamic_system, DefaultReport())
simulation_strategy = ThreadControl()
event_control = DiscreteEventControl(simulator, simulation_strategy)
class gsf.control.controls.thread_control.ThreadControlStrategy

Bases: gsf.control.core.simulation_strategy.SimulationStrategy

Strategy that executes the simulation in a new thread

_thread

Current thread of the simulation.

Type

Thread

start_simulation(target: Callable, frequency: decimal.Decimal = 0, wait_time: decimal.Decimal = 0, stop_time: decimal.Decimal = 0)

Creates a new simulation thread with the specified target.

Parameters
  • target (Callable) – Method to be called to run the simulation.

  • frequency (Time) – Frequency of the simulation computation.

  • wait_time (Time) – Delay execution for a given.

  • stop_time (Time) – Duration of the simulation.

stop_simulation()

Deletes the simulation thread.

wait_simulation(timeout: Optional[decimal.Decimal] = None)

Merges the created thread to the main thread.

Parameters

timeout (Time) – time to merge.