X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/db9ef2223acb402e44eec406541e671bfebd5ade..5a006fa396cfcc8a91a8284f0d625b2a9a2565c9:/src/s4u/s4u_Engine.cpp diff --git a/src/s4u/s4u_Engine.cpp b/src/s4u/s4u_Engine.cpp index 76166e0f19..e808263551 100644 --- a/src/s4u/s4u_Engine.cpp +++ b/src/s4u/s4u_Engine.cpp @@ -1,6 +1,6 @@ /* s4u::Engine Simulation Engine and global functions. */ -/* 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. */ @@ -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; @@ -212,7 +208,7 @@ Host* Engine::host_by_name(const std::string& name) const { auto* host = host_by_name_or_null(name); if (not host) - throw std::invalid_argument(std::string("Host not found: '") + name + std::string("'")); + throw std::invalid_argument("Host not found: '" + name + "'"); return host; } @@ -236,7 +232,7 @@ Link* Engine::link_by_name(const std::string& name) const { auto* link = link_by_name_or_null(name); if (not link) - throw std::invalid_argument(std::string("Link not found: ") + name); + throw std::invalid_argument("Link not found: " + name); return link; } @@ -244,7 +240,7 @@ SplitDuplexLink* Engine::split_duplex_link_by_name(const std::string& name) cons { auto* link_impl = pimpl->netzone_root_ ? pimpl->netzone_root_->get_split_duplex_link_by_name_or_null(name) : nullptr; if (not link_impl) - throw std::invalid_argument(std::string("Link not found: ") + name); + throw std::invalid_argument("Link not found: " + name); return link_impl->get_iface(); } @@ -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_.try_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; } @@ -401,7 +396,7 @@ kernel::routing::NetPoint* Engine::netpoint_by_name(const std::string& name) con { auto netp = netpoint_by_name_or_null(name); if (netp == nullptr) { - throw std::invalid_argument(std::string("Netpoint not found: %s") + name); + throw std::invalid_argument("Netpoint not found: " + name); } return netp; } @@ -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) @@ -501,13 +495,5 @@ double simgrid_get_clock() void simgrid_set_maestro(void (*code)(void*), void* data) { -#ifdef _WIN32 - XBT_WARN("simgrid_set_maestro is believed to not work on windows. Please help us investigating this issue if " - "you need that feature"); -#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); -}