- void my_actor(int param1, double param2, std::string param3) {
- ...
- }
- int main(int argc, char argv**) {
- ...
- simgrid::s4u::ActorPtr actor;
- actor = simgrid::s4u::Actor::create("name", simgrid::s4u::Host::by_name("the_host"),
- &my_actor, 42, 3.14, "thevalue");
- ...
- }
+ ``Actor::create(name, host, func, params...)`` is a very flexible
+ function. Its third parameter is the function that the actor should
+ execute. This function can take any kind of parameter, provided that
+ you pass similar parameters to ``Actor::create()``. For example, you
+ could have something like this:
+
+ .. code-block:: cpp
+
+ void my_actor(int param1, double param2, std::string param3) {
+ ...
+ }
+ int main(int argc, char argv**) {
+ ...
+ simgrid::s4u::ActorPtr actor;
+ actor = simgrid::s4u::Actor::create("name", simgrid::s4u::Host::by_name("the_host"),
+ &my_actor, 42, 3.14, "thevalue");
+ ...
+ }
+
+ .. group-tab:: Python
+
+ For that, the master needs to retrieve the list of hosts declared in
+ the platform with :py:func:`simgrid.Engine.get_all_hosts`. Since this method is not static,
+ you may want to call it on the Engine instance, as in ``Engine.instance().get_all_hosts()``.
+ Then, the master should start the worker actors with :py:func:`simgrid.Actor.create`.
+
+ ``Actor.create(name, host, func, params...)`` is a very flexible
+ function. Its third parameter is the function that the actor should
+ execute. This function can take any kind of parameter, provided that
+ you pass similar parameters to ``Actor.create()``. For example, you
+ could have something like this:
+
+ .. code-block:: python
+
+ def my_actor(param1, param2, param3):
+ # your code comes here
+ actor = simgrid.Actor.create("name", the_host, my_actor, 42, 3.14, "thevalue")