X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ea10e88fd41a11386d9e3868d72ab8cb933a4292..021e27fc5af34eab44297b9a49a53a65b27f6865:/include/simgrid/s4u/Mailbox.hpp diff --git a/include/simgrid/s4u/Mailbox.hpp b/include/simgrid/s4u/Mailbox.hpp index d48166dfe3..b8eddff976 100644 --- a/include/simgrid/s4u/Mailbox.hpp +++ b/include/simgrid/s4u/Mailbox.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -10,13 +10,11 @@ #include #include #include -#include #include #include -namespace simgrid { -namespace s4u { +namespace simgrid::s4u { /** @brief Mailboxes: Network rendez-vous points. */ class XBT_PUBLIC Mailbox { @@ -36,11 +34,11 @@ protected: public: /** @brief Retrieves the name of that mailbox as a C++ string */ - const xbt::string& get_name() const; + const std::string& get_name() const; /** @brief Retrieves the name of that mailbox as a C string */ const char* get_cname() const; - /** Retrieve the mailbox associated to the given name. Mailboxes are created on demand. */ + /** \static Retrieve the mailbox associated to the given name. Mailboxes are created on demand. */ static Mailbox* by_name(const std::string& name); /** Returns whether the mailbox contains queued communications */ @@ -55,7 +53,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 */ @@ -116,6 +118,9 @@ public: CommPtr get_init(); /** Creates and start an async data reception to that mailbox */ template CommPtr get_async(T** data); + /** Creates and start an async data reception to that mailbox. Since the data location is not provided, you'll have to + * use Comm::get_payload once the comm terminates */ + CommPtr get_async(); /** Blocking data reception */ template T* get(); @@ -126,13 +131,12 @@ public: template std::unique_ptr get_unique(double timeout) { return std::unique_ptr(get(timeout)); } void clear(); - }; template CommPtr Mailbox::get_async(T** data) { CommPtr res = get_init()->set_dst_data(reinterpret_cast(data), sizeof(void*)); - res->vetoable_start(); + res->start(); return res; } @@ -149,7 +153,6 @@ template T* Mailbox::get(double timeout) get_async(&res)->wait_for(timeout); return res; } -} // namespace s4u -} // namespace simgrid +} // namespace simgrid::s4u #endif /* SIMGRID_S4U_MAILBOX_HPP */