X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2ce92bd5e85ca03543857c05b5120153e7136baa..9db79d70d969bdb58f26c689ad4f965b3d9e80cf:/src/kernel/resource/WifiLinkImpl.cpp diff --git a/src/kernel/resource/WifiLinkImpl.cpp b/src/kernel/resource/WifiLinkImpl.cpp index 92ebf0b7aa..a40a12a6e6 100644 --- a/src/kernel/resource/WifiLinkImpl.cpp +++ b/src/kernel/resource/WifiLinkImpl.cpp @@ -1,13 +1,13 @@ -/* Copyright (c) 2019-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2019-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. */ +#include #include -#include "src/kernel/resource/WifiLinkImpl.hpp" -#include "src/surf/surf_interface.hpp" #include "src/kernel/activity/CommImpl.hpp" +#include "src/kernel/resource/WifiLinkImpl.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network); @@ -16,6 +16,21 @@ namespace simgrid::kernel::resource { /************ * Resource * ************/ +static void update_bw_comm_start(const s4u::Comm& comm) +{ + const auto* pimpl = static_cast(comm.get_impl()); + + auto const* actionWifi = dynamic_cast(pimpl->model_action_); + if (actionWifi == nullptr) + return; + + if (auto* link_src = actionWifi->get_src_link()) { + link_src->inc_active_flux(); + } + if (auto* link_dst = actionWifi->get_dst_link()) { + link_dst->inc_active_flux(); + } +} WifiLinkImpl::WifiLinkImpl(const std::string& name, const std::vector& bandwidths, lmm::System* system) : StandardLinkImpl(name) @@ -23,7 +38,7 @@ WifiLinkImpl::WifiLinkImpl(const std::string& name, const std::vector& b this->set_constraint(system->constraint_new(this, 1)); for (auto bandwidth : bandwidths) bandwidths_.push_back({bandwidth, 1.0, nullptr}); - kernel::activity::CommImpl::on_start.connect(&update_bw_comm_start); + s4u::Comm::on_start_cb(&update_bw_comm_start); s4u::Link::on_communication_state_change_cb(&update_bw_comm_end); } @@ -80,20 +95,6 @@ void WifiLinkImpl::dec_active_flux() nb_active_flux_--; } -void WifiLinkImpl::update_bw_comm_start(const kernel::activity::CommImpl& comm) -{ - auto const* actionWifi = dynamic_cast(comm.surf_action_); - if (actionWifi == nullptr) - return; - - if (auto* link_src = actionWifi->get_src_link()) { - link_src->inc_active_flux(); - } - if (auto* link_dst = actionWifi->get_dst_link()) { - link_dst->inc_active_flux(); - } -} - void WifiLinkImpl::update_bw_comm_end(const simgrid::kernel::resource::NetworkAction& action, simgrid::kernel::resource::Action::State /*state*/) { @@ -114,7 +115,7 @@ void WifiLinkImpl::update_bw_comm_end(const simgrid::kernel::resource::NetworkAc double WifiLinkImpl::get_max_ratio() const { - double new_peak = -1; + double new_peak; if (nb_active_flux_ > conc_lim_) { new_peak = (nb_active_flux_-conc_lim_) * co_acc_ + x0_; XBT_DEBUG("Wi-Fi link peak=(%d-%d)*%lf+%lf=%lf", nb_active_flux_, conc_lim_, co_acc_, x0_, new_peak);