Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Align exec-async with C++ example (also define python binding).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 21 Apr 2022 14:00:22 +0000 (16:00 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 22 Apr 2022 09:50:21 +0000 (11:50 +0200)
examples/c/exec-async/exec-async.c
examples/python/exec-async/exec-async.py
src/bindings/python/simgrid_python.cpp

index eebc8d0..64430fd 100644 (file)
@@ -49,8 +49,7 @@ static void canceller(int argc, char* argv[])
   double computation_amount = sg_host_get_speed(sg_host_self());
 
   XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
-  sg_exec_t activity = sg_actor_exec_init(computation_amount);
-  sg_exec_start(activity);
+  sg_exec_t activity = sg_actor_exec_async(computation_amount);
   sg_actor_sleep_for(0.5);
   XBT_INFO("I changed my mind, cancel!");
   sg_exec_cancel(activity);
index 0758543..707d03d 100644 (file)
@@ -50,7 +50,7 @@ class Canceller:
     def __call__(self):
         computation_amount = this_actor.get_host().speed
         this_actor.info("Canceller executes {:.0f} flops, should take 1 second.".format(computation_amount))
-        activity = this_actor.exec_init(computation_amount).start()
+        activity = this_actor.exec_async(computation_amount)
 
         this_actor.sleep_for(0.5)
         this_actor.info("I changed my mind, cancel!")
index 4b09a55..db71ba4 100644 (file)
@@ -120,6 +120,8 @@ PYBIND11_MODULE(simgrid, m)
            py::arg("priority") = 1)
       .def("exec_init", py::overload_cast<double>(&simgrid::s4u::this_actor::exec_init),
            py::call_guard<py::gil_scoped_release>())
+      .def("exec_async", py::overload_cast<double>(&simgrid::s4u::this_actor::exec_async),
+           py::call_guard<py::gil_scoped_release>())
       .def("get_host", &simgrid::s4u::this_actor::get_host, "Retrieves host on which the current actor is located")
       .def("set_host", &simgrid::s4u::this_actor::set_host, py::call_guard<py::gil_scoped_release>(),
            "Moves the current actor to another host.", py::arg("dest"))