X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/18080b8f80c81ed30600da55f774a52cbd1101f8..d94f920eb99dc33e8c592e89bcbbb3a8e50fe919:/src/s4u/s4u_Engine.cpp diff --git a/src/s4u/s4u_Engine.cpp b/src/s4u/s4u_Engine.cpp index 858ee1f367..8da467da70 100644 --- a/src/s4u/s4u_Engine.cpp +++ b/src/s4u/s4u_Engine.cpp @@ -9,9 +9,6 @@ #include #include -#define SIMIX_H_NO_DEPRECATED_WARNING // avoid deprecation warning on include (remove with XBT_ATTRIB_DEPRECATED_v333) -#include - #include "mc/mc.h" #include "src/instr/instr_private.hpp" #include "src/kernel/EngineImpl.hpp" @@ -30,8 +27,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_engine, s4u, "Logging specific to S4U (engin static simgrid::kernel::actor::ActorCode maestro_code; -namespace simgrid { -namespace s4u { +namespace simgrid::s4u { xbt::signal Engine::on_platform_creation; xbt::signal Engine::on_platform_created; xbt::signal Engine::on_simulation_start; @@ -268,12 +264,12 @@ Mailbox* Engine::mailbox_by_name_or_create(const std::string& name) const { /* two actors may have pushed the same mbox_create simcall at the same time */ kernel::activity::MailboxImpl* mbox = kernel::actor::simcall_answered([&name, this] { - auto m = pimpl->mailboxes_.emplace(name, nullptr); - if (m.second) { - m.first->second = new kernel::activity::MailboxImpl(name); - XBT_DEBUG("Creating a mailbox at %p with name %s", m.first->second, name.c_str()); + auto [m, inserted] = pimpl->mailboxes_.try_emplace(name, nullptr); + if (inserted) { + m->second = new kernel::activity::MailboxImpl(name); + XBT_DEBUG("Creating a mailbox at %p with name %s", m->second, name.c_str()); } - return m.first->second; + return m->second; }); return mbox->get_iface(); } @@ -317,8 +313,8 @@ size_t Engine::get_actor_count() const std::vector Engine::get_all_actors() const { std::vector actor_list; - for (auto const& kv : pimpl->get_actor_list()) { - actor_list.push_back(kv.second->get_iface()); + for (auto const& [_, actor] : pimpl->get_actor_list()) { + actor_list.push_back(actor->get_iface()); } return actor_list; } @@ -326,9 +322,9 @@ std::vector Engine::get_all_actors() const std::vector Engine::get_filtered_actors(const std::function& filter) const { std::vector actor_list; - for (auto const& kv : pimpl->get_actor_list()) { - if (filter(kv.second->get_iface())) - actor_list.push_back(kv.second->get_iface()); + for (auto const& [_, actor] : pimpl->get_actor_list()) { + if (filter(actor->get_iface())) + actor_list.push_back(actor->get_iface()); } return actor_list; } @@ -339,8 +335,7 @@ void Engine::run() const } void Engine::run_until(double max_date) const { - static bool callback_called = false; - if (not callback_called) { + if (static bool callback_called = false; not callback_called) { on_simulation_start(); callback_called = true; } @@ -409,8 +404,8 @@ kernel::routing::NetPoint* Engine::netpoint_by_name(const std::string& name) con std::vector Engine::get_all_netpoints() const { std::vector res; - for (auto const& kv : pimpl->netpoints_) - res.push_back(kv.second); + for (auto const& [_, netpoint] : pimpl->netpoints_) + res.push_back(netpoint); return res; } @@ -461,8 +456,7 @@ Engine* Engine::set_default_comm_data_copy_callback( return this; } -} // namespace s4u -} // namespace simgrid +} // namespace simgrid::s4u /* **************************** Public C interface *************************** */ void simgrid_init(int* argc, char** argv) @@ -507,7 +501,3 @@ void simgrid_set_maestro(void (*code)(void*), void* data) #endif maestro_code = std::bind(code, data); } -void SIMIX_set_maestro(void (*code)(void*), void* data) // XBT_ATTRIB_DEPRECATED_v333 -{ - simgrid_set_maestro(code, data); -}