# application and the settings to test it. This is a better scientific methodology. Actually, starting an actor with
# Actor.create() is mostly useful to start an actor from another actor.
# application and the settings to test it. This is a better scientific methodology. Actually, starting an actor with
# Actor.create() is mostly useful to start an actor from another actor.
# Our first class of actors is simply implemented with a function, that takes a single string as parameter.
#
# Later, this actor class is instantiated within the simulation.
def receiver(mailbox_name):
# Our first class of actors is simply implemented with a function, that takes a single string as parameter.
#
# Later, this actor class is instantiated within the simulation.
def receiver(mailbox_name):
- simgrid.info("I received '{:s}', '{:s}' and '{:s}'".format(msg1, msg2, msg3))
- simgrid.info("I'm done. See you.")
+ this_actor.info("I received '{:s}', '{:s}' and '{:s}'".format(msg1, msg2, msg3))
+ this_actor.info("I'm done. See you.")
# Our second class of actors is also a function
def forwarder(*args):
if len(args) < 2: raise AssertionError("Actor forwarder requires 2 parameters, but got only {:d}".format(len(args)))
# Our second class of actors is also a function
def forwarder(*args):
if len(args) < 2: raise AssertionError("Actor forwarder requires 2 parameters, but got only {:d}".format(len(args)))
mb_out.put(msg, len(msg))
# Declares a third class of actors which sends a message to the mailbox 'mb42'.
mb_out.put(msg, len(msg))
# Declares a third class of actors which sends a message to the mailbox 'mb42'.
- simgrid.info("Hello s4u, I have something to send")
- mailbox = simgrid.Mailbox.by_name(self.mbox)
+ this_actor.info("Hello s4u, I have something to send")
+ mailbox = Mailbox.by_name(self.mbox)
# Here comes the main function of your program
if __name__ == '__main__':
# When your program starts, you have to first start a new simulation engine, as follows
# Here comes the main function of your program
if __name__ == '__main__':
# When your program starts, you have to first start a new simulation engine, as follows
# Then you should load a platform file, describing your simulated platform
e.load_platform("../../platforms/small_platform.xml");
# Then you should load a platform file, describing your simulated platform
e.load_platform("../../platforms/small_platform.xml");
# 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.
# 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.
- simgrid.Actor.create("receiver", simgrid.Host.by_name("Fafard"), receiver, "mb42")
+ 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:
# 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:
# 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
# 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