From f4f204534b969a5efddf4861c7abc6ca03ccb560 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 4 Feb 2020 11:13:36 +0100 Subject: [PATCH] Add the 2 new C examples to the doc; use sg_comm_wait_any in example instead of sg_comm_wait_any_for --- docs/source/app_s4u.rst | 2 +- examples/README.rst | 11 +++++++++++ examples/c/async-waitany/async-waitany.c | 2 +- include/simgrid/comm.h | 1 + src/s4u/s4u_Comm.cpp | 4 ++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/source/app_s4u.rst b/docs/source/app_s4u.rst index 1991185198..d1d5128296 100644 --- a/docs/source/app_s4u.rst +++ b/docs/source/app_s4u.rst @@ -988,7 +988,7 @@ See :ref:`s4u_receiving_actor`. .. group-tab:: C - .. autodoxymethod:: ::sg_mailbox_set_receiver(const char *alias) + .. autodoxymethod:: sg_mailbox_set_receiver(const char *alias) .. _API_s4u_Resource: diff --git a/examples/README.rst b/examples/README.rst index 810c7b990f..d02d5085f3 100644 --- a/examples/README.rst +++ b/examples/README.rst @@ -54,6 +54,13 @@ Starting and Stoping Actors - Directly with :py:func:`simgrid.Actor.create()` - From XML with :py:func:`simgrid.Engine.register_actor()` and then :py:func:`simgrid.Engine.load_deployment()` + .. example-tab:: examples/c/actor-create/actor-create.c + + You create actors either: + + - Directly with :cpp:func:`sg_actor_create()` followed by :cpp:func:`sg_actor_start`. + - From XML with :cpp:func:`simgrid_register_function` and then :cpp:func:`simgrid_load_deployment`. + .. example-tab:: examples/python/actor-create/actor-create_d.xml The following file is used in both C++ and Python. @@ -268,6 +275,10 @@ Communications on the Network .. example-tab:: examples/python/async-waitany/async-waitany.py See also :py:func:`simgrid.Comm.wait_any()`. + + .. example-tab:: examples/c/async-waitany/async-waitany.c + + See also :cpp:func:`sg_comm_wait_any`. .. _s4u_ex_execution: diff --git a/examples/c/async-waitany/async-waitany.c b/examples/c/async-waitany/async-waitany.c index cfe912776d..73eaae32fd 100644 --- a/examples/c/async-waitany/async-waitany.c +++ b/examples/c/async-waitany/async-waitany.c @@ -63,7 +63,7 @@ static int sender(int argc, char* argv[]) * Even in this simple example, the pending comms do not terminate in the exact same order of creation. */ while (pending_comms_count != 0) { - int changed_pos = sg_comm_wait_any_for(pending_comms, pending_comms_count, -1); + int changed_pos = sg_comm_wait_any(pending_comms, pending_comms_count); memmove(pending_comms + changed_pos, pending_comms + changed_pos + 1, sizeof(sg_comm_t) * (pending_comms_count - changed_pos - 1)); pending_comms_count--; diff --git a/include/simgrid/comm.h b/include/simgrid/comm.h index 933cd70b1c..e3b3cd1371 100644 --- a/include/simgrid/comm.h +++ b/include/simgrid/comm.h @@ -13,6 +13,7 @@ SG_BEGIN_DECL XBT_PUBLIC int sg_comm_wait_any_for(sg_comm_t* comms, size_t count, double timeout); +XBT_PUBLIC int sg_comm_wait_any(sg_comm_t* comms, size_t count); SG_END_DECL diff --git a/src/s4u/s4u_Comm.cpp b/src/s4u/s4u_Comm.cpp index 9eabf307d3..49edc9fb22 100644 --- a/src/s4u/s4u_Comm.cpp +++ b/src/s4u/s4u_Comm.cpp @@ -254,6 +254,10 @@ Actor* Comm::get_sender() } // namespace s4u } // namespace simgrid /* **************************** Public C interface *************************** */ +int sg_comm_wait_any(sg_comm_t* comms, size_t count) +{ + return sg_comm_wait_any_for(comms, count, -1); +} int sg_comm_wait_any_for(sg_comm_t* comms, size_t count, double timeout) { std::vector s4u_comms; -- 2.20.1