X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/237fd22b56db7d1c67360c37559ce3aab16a002d..40ee10e13b61bfb28374d96ade010a262b5abd44:/include/simgrid/s4u/Mailbox.hpp diff --git a/include/simgrid/s4u/Mailbox.hpp b/include/simgrid/s4u/Mailbox.hpp index 9687ef9ea9..b8eddff976 100644 --- a/include/simgrid/s4u/Mailbox.hpp +++ b/include/simgrid/s4u/Mailbox.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2021. 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 */ @@ -99,8 +101,8 @@ public: */ CommPtr put_async(void* data, uint64_t simulated_size_in_bytes); - kernel::activity::ActivityImplPtr iprobe(int type, bool (*match_fun)(void*, void*, kernel::activity::CommImpl*), - void* data); + kernel::activity::ActivityImplPtr + iprobe(int type, const std::function& match_fun, void* data); /** Blocking data transmission. * * Please note that if you send a pointer to some data, you must ensure that your data remains live during the @@ -110,10 +112,15 @@ public: /** Blocking data transmission with timeout */ void put(void* payload, uint64_t simulated_size_in_bytes, double timeout); - /** Creates (but don't start) a data reception onto that mailbox */ + /** Creates (but don't start) a data reception onto that mailbox. + * @verbatim embed:rst:inline You probably want to use :cpp:func:`simgrid::s4u::Comm::set_dst_data` and friends before + * starting that activity. @endverbatim */ 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(); @@ -123,17 +130,13 @@ public: template T* get(double timeout); template std::unique_ptr get_unique(double timeout) { return std::unique_ptr(get(timeout)); } -#ifndef DOXYGEN - XBT_ATTRIB_DEPRECATED_v331("Please use typed template Mailbox::get_async<>()") CommPtr get_async(void** data); - XBT_ATTRIB_DEPRECATED_v331("Please use typed template Mailbox::get<>()") void* get(); - XBT_ATTRIB_DEPRECATED_v331("Please use typed template Mailbox::get<>()") void* get(double timeout); -#endif + 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; } @@ -150,22 +153,6 @@ template T* Mailbox::get(double timeout) get_async(&res)->wait_for(timeout); return res; } - -#ifndef DOXYGEN -inline CommPtr Mailbox::get_async(void** data) // XBT_ATTRIB_DEPRECATED_v331 -{ - return get_async(data); -} -inline void* Mailbox::get() // XBT_ATTRIB_DEPRECATED_v331 -{ - return get(); -} -inline void* Mailbox::get(double timeout) // XBT_ATTRIB_DEPRECATED_v331 -{ - return get(timeout); -} -#endif -} // namespace s4u -} // namespace simgrid +} // namespace simgrid::s4u #endif /* SIMGRID_S4U_MAILBOX_HPP */