From: Frederic Suter Date: Mon, 31 Jul 2017 09:18:00 +0000 (+0200) Subject: this dict was a set X-Git-Tag: v3_17~306 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/390af2c5e4f9783762fadc35bd0f3cac32961827 this dict was a set --- diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 6d3b3b9c32..173dcf4759 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -374,11 +374,6 @@ XBT_PUBLIC_DATA(s_surf_model_description_t) surf_host_model_description[]; */ XBT_PUBLIC(void) surf_vm_model_init_HL13(); -/** \ingroup SURF_simulation - * \brief List of hosts for which one want to be notified if they ever restart. - */ -XBT_PUBLIC_DATA(xbt_dict_t) watched_hosts_lib; - /*** SURF Globals **************************/ /** \ingroup SURF_simulation diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 3fb82a4878..fda196e0f5 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -8,6 +8,7 @@ #include "src/kernel/activity/CommImpl.hpp" #include "src/mc/mc_replay.h" #include "src/plugins/vm/VirtualMachineImpl.hpp" +#include "src/surf/surf_interface.hpp" #include "xbt/ex.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_host, simix, "SIMIX hosts"); @@ -124,9 +125,9 @@ void SIMIX_host_add_auto_restart_process( arg->properties = properties; arg->auto_restart = auto_restart; - if (host->isOff() && not xbt_dict_get_or_null(watched_hosts_lib, host->getCname())) { - xbt_dict_set(watched_hosts_lib, host->getCname(), host, nullptr); - XBT_DEBUG("Push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF", host->getCname()); + if (host->isOff() && watched_hosts.find(host->getCname()) == watched_hosts.end()) { + watched_hosts.insert(host->getCname()); + XBT_DEBUG("Push host %s to watched_hosts because state == SURF_RESOURCE_OFF", host->getCname()); } host->extension()->auto_restart_processes.push_back(arg); } diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 46f00dedd5..d459a4d80b 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -100,7 +100,7 @@ double surf_solve(double max_date) XBT_DEBUG("Updating models (min = %g, NOW = %g, next_event_date = %g)", time_delta, NOW, next_event_date); while ((event = future_evt_set->pop_leq(next_event_date, &value, &resource))) { - if (resource->isUsed() || xbt_dict_get_or_null(watched_hosts_lib, resource->cname())) { + if (resource->isUsed() || (watched_hosts.find(resource->cname()) != watched_hosts.end())) { time_delta = next_event_date - NOW; XBT_DEBUG("This event invalidates the next_occuring_event() computation of models. Next event set to %f", time_delta); } diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 07493f0dbb..f99f0ee2ba 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -12,6 +12,8 @@ #include "src/surf/HostImpl.hpp" #include +#include +#include #include XBT_LOG_NEW_CATEGORY(surf, "All SURF categories"); @@ -26,7 +28,8 @@ std::vector * all_existing_models = nullptr; /* to destroy models simgrid::trace_mgr::future_evt_set *future_evt_set = nullptr; std::vector surf_path; std::vector host_that_restart; -xbt_dict_t watched_hosts_lib; +/** set of hosts for which one want to be notified if they ever restart. */ +std::set watched_hosts; extern std::map storage_types; namespace simgrid { @@ -345,8 +348,6 @@ void surf_init(int *argc, char **argv) XBT_DEBUG("Create all Libs"); USER_HOST_LEVEL = simgrid::s4u::Host::extension_create(nullptr); - watched_hosts_lib = xbt_dict_new_homogeneous(nullptr); - xbt_init(argc, argv); if (not all_existing_models) all_existing_models = new std::vector(); @@ -368,7 +369,6 @@ void surf_exit() sg_host_exit(); sg_link_exit(); - xbt_dict_free(&watched_hosts_lib); for (auto e : storage_types) { storage_type_t stype = e.second; free(stype->model); diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 63a79ae068..8ab050fd83 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -13,6 +13,7 @@ #include "xbt/str.h" #include +#include #include #include @@ -31,6 +32,7 @@ extern XBT_PRIVATE double sg_weight_S_parameter; extern XBT_PRIVATE int sg_network_crosstraffic; extern XBT_PRIVATE std::vector surf_path; extern XBT_PRIVATE std::unordered_map traces_set_list; +extern XBT_PRIVATE std::set watched_hosts; extern "C" { XBT_PUBLIC(double) surf_get_clock(); diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 5a53d7ada7..7d3fa1f45c 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -14,8 +14,6 @@ SG_BEGIN_DECL() -XBT_PUBLIC_DATA(xbt_dict_t) watched_hosts_lib; - extern XBT_PRIVATE const char *surf_action_state_names[6]; /** @ingroup SURF_interface