From 28f805fae0e23649a7ce5eb7157abdeacb6f7ad8 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 21 Apr 2022 16:00:22 +0200 Subject: [PATCH] Align exec-async with C++ example (also define python binding). --- examples/c/exec-async/exec-async.c | 3 +-- examples/python/exec-async/exec-async.py | 2 +- src/bindings/python/simgrid_python.cpp | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/c/exec-async/exec-async.c b/examples/c/exec-async/exec-async.c index eebc8d064e..64430fd9f5 100644 --- a/examples/c/exec-async/exec-async.c +++ b/examples/c/exec-async/exec-async.c @@ -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); diff --git a/examples/python/exec-async/exec-async.py b/examples/python/exec-async/exec-async.py index 07585437a3..707d03d100 100644 --- a/examples/python/exec-async/exec-async.py +++ b/examples/python/exec-async/exec-async.py @@ -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!") diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index 4b09a553ce..db71ba46d9 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -120,6 +120,8 @@ PYBIND11_MODULE(simgrid, m) py::arg("priority") = 1) .def("exec_init", py::overload_cast(&simgrid::s4u::this_actor::exec_init), py::call_guard()) + .def("exec_async", py::overload_cast(&simgrid::s4u::this_actor::exec_async), + py::call_guard()) .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(), "Moves the current actor to another host.", py::arg("dest")) -- 2.20.1