Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Then you should load a platform file, describing your simulated platform
e.load_platform("../../platforms/small_platform.xml")
# And now you have to ask SimGrid to actually start your actors.
#
# The easiest way to do so is to implement the behavior of your actor in a single function,
# as we do here for the receiver actors. This function can take any kind of parameters, as
# long as the last parameters of Actor::create() match what your function expects.
Actor.create("receiver", Host.by_name("Fafard"), receiver, "mb42")
# If your actor is getting more complex, you probably want to implement it as a class instead,
# as we do here for the sender actors. The main behavior goes into operator()() of the class.
#
# You can then directly start your actor, as follows:
Actor.create("sender1", Host.by_name("Tremblay"), Sender())
# If you want to pass parameters to your class, that's very easy: just use your constructors
Actor.create("sender2", Host.by_name("Jupiter"), Sender("GloubiBoulga"))
# But starting actors directly is considered as a bad experimental habit, since it ties the code
# you want to test with the experimental scenario. Starting your actors from an external deployment
# file in XML ensures that you can test your code in several scenarios without changing the code itself.
#
# For that, you first need to register your function or your actor as follows.
e.register_actor("sender", Sender)
e.register_actor("forwarder", forwarder)
# Once actors and functions are registered, just load the deployment file
e.load_deployment("actor-create_d.xml")
# Once every actors are started in the engine, the simulation can start
e.run()