X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/63dae9fee48b67ed8302130aa84c8a54cd42241b..dc122c0fb3802061bc2fdb4abd50bf02a224cfdc:/src/surf/LinkImpl.cpp diff --git a/src/surf/LinkImpl.cpp b/src/surf/LinkImpl.cpp index 3bef2d1730..a5a34ae20e 100644 --- a/src/surf/LinkImpl.cpp +++ b/src/surf/LinkImpl.cpp @@ -3,9 +3,10 @@ /* 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 "src/kernel/EngineImpl.hpp" #include "src/surf/LinkImpl.hpp" -#include "simgrid/s4u/Engine.hpp" -#include "surf/surf.hpp" #include @@ -34,27 +35,28 @@ LinkImpl::LinkImpl(const std::string& name) : LinkImplIntf(name), piface_(this) */ void LinkImpl::destroy() { - s4u::Link::on_destruction(this->piface_); + s4u::Link::on_destruction(piface_); + s4u::Engine::get_instance()->link_unregister(get_name()); delete this; } -bool LinkImpl::is_used() const +constexpr kernel::lmm::Constraint::SharingPolicy to_maxmin_policy(s4u::Link::SharingPolicy policy) { - return get_model()->get_maxmin_system()->constraint_used(get_constraint()); + switch (policy) { + case s4u::Link::SharingPolicy::NONLINEAR: + return kernel::lmm::Constraint::SharingPolicy::NONLINEAR; + case s4u::Link::SharingPolicy::FATPIPE: + return kernel::lmm::Constraint::SharingPolicy::FATPIPE; + default: + return kernel::lmm::Constraint::SharingPolicy::SHARED; + } } -void LinkImpl::set_sharing_policy(s4u::Link::SharingPolicy policy) +void LinkImpl::set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb) { - lmm::Constraint::SharingPolicy ct_policy = lmm::Constraint::SharingPolicy::SHARED; - if (policy == s4u::Link::SharingPolicy::FATPIPE) - ct_policy = lmm::Constraint::SharingPolicy::FATPIPE; - get_constraint()->set_sharing_policy(ct_policy); + get_constraint()->set_sharing_policy(to_maxmin_policy(policy), cb); sharing_policy_ = policy; } -s4u::Link::SharingPolicy LinkImpl::get_sharing_policy() const -{ - return sharing_policy_; -} void LinkImpl::latency_check(double latency) const { @@ -82,7 +84,7 @@ void LinkImpl::turn_off() s4u::Link::on_state_change(piface_); const kernel::lmm::Element* elem = nullptr; - double now = surf_get_clock(); + double now = EngineImpl::get_clock(); while (const auto* var = get_constraint()->get_variable(&elem)) { Action* action = var->get_id(); if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED) { @@ -100,7 +102,6 @@ void LinkImpl::seal() xbt_assert(this->get_model(), "Cannot seal Link(%s) without setting the Network model first", this->get_cname()); Resource::seal(); - s4u::Link::on_creation(piface_); } void LinkImpl::on_bandwidth_change() const @@ -134,4 +135,4 @@ void LinkImpl::set_concurrency_limit(int limit) const } // namespace resource } // namespace kernel -} // namespace simgrid \ No newline at end of file +} // namespace simgrid