From f8b3dd62a8a5d07757ba14daad3846b4871d3cc3 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 21 Jan 2023 22:22:26 +0100 Subject: [PATCH] Yet another example integrated in the doc --- examples/README.rst | 19 +++++++++++++++++++ include/simgrid/s4u/Mailbox.hpp | 6 +++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/examples/README.rst b/examples/README.rst index e3cd9fe740..7fc106b6d2 100644 --- a/examples/README.rst +++ b/examples/README.rst @@ -358,6 +358,25 @@ This example is very similar to the previous one, simply adding how to declare t See also :py:func:`simgrid.Comm.wait_until()` +.. _s4u_ex_mailbox_ready: + +Checking for incoming communications +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This example uses ``Mailbox.ready()`` to check for completed communications. When this function returns true, then at least a message +is arrived, so you know that ``Mailbox.get()`` will complete imediately. This is thus another way toward asynchronous communications. + +.. tabs:: + + .. example-tab:: examples/cpp/comm-ready/s4u-comm-ready.cpp + + See also :cpp:func:`simgrid::s4u::Mailbox::ready()`. + + .. example-tab:: examples/python/comm-ready/comm-ready.py + + See also :py:func:`simgrid.Mailbox.ready()` + + Suspending communications ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/include/simgrid/s4u/Mailbox.hpp b/include/simgrid/s4u/Mailbox.hpp index 84db62a2b3..3c910f6632 100644 --- a/include/simgrid/s4u/Mailbox.hpp +++ b/include/simgrid/s4u/Mailbox.hpp @@ -54,7 +54,11 @@ public: /** Look if there is a communication going on in a mailbox and return the PID of the sender actor */ aid_t listen_from() const; - /** Check if there is a communication ready to be consumed from a mailbox. */ + /** Check if there is a communication ready to be consumed from a mailbox. + * \beginrst + * See :ref:`this example `. + * \endrst + */ bool ready() const; /** Gets the first element in the queue (without dequeuing it), or nullptr if none is there */ -- 2.20.1