X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0199ba108d66c94df94e4f044994e79efdece4b1..3f367762081b50ecd16c09ef850e2daa823a99a0:/src/s4u/s4u_Link.cpp diff --git a/src/s4u/s4u_Link.cpp b/src/s4u/s4u_Link.cpp index 1a5db6cde0..2e2a3ba652 100644 --- a/src/s4u/s4u_Link.cpp +++ b/src/s4u/s4u_Link.cpp @@ -10,7 +10,7 @@ #include "simgrid/s4u/Link.hpp" #include "simgrid/sg_config.hpp" #include "simgrid/simix.hpp" -#include "src/kernel/lmm/maxmin.hpp" +#include "src/surf/SplitDuplexLinkImpl.hpp" #include "src/surf/network_interface.hpp" #include "src/surf/network_wifi.hpp" #include "xbt/log.h" @@ -35,6 +35,16 @@ Link* Link::by_name(const std::string& name) return Engine::get_instance()->link_by_name(name); } +kernel::resource::LinkImpl* Link::get_impl() const +{ + auto* link_impl = dynamic_cast(pimpl_); + xbt_assert(link_impl != nullptr, "Impossible to get a LinkImpl* from link. %s.", + (get_sharing_policy() == SharingPolicy::SPLITDUPLEX + ? "For a Split-Duplex link, you should call this method to each UP/DOWN member" + : "Please report this bug")); + return link_impl; +} + Link* Link::by_name_or_null(const std::string& name) { return Engine::get_instance()->link_by_name_or_null(name); @@ -96,7 +106,7 @@ Link* Link::set_sharing_policy(Link::SharingPolicy policy) { if (policy == SharingPolicy::SPLITDUPLEX) throw std::invalid_argument(std::string("Impossible to set split-duplex for the link: ") + get_name() + - std::string(". You should create a link-up and link-down to emulate this behavior")); + std::string(". Use NetZone::create_split_duplex_link.")); kernel::actor::simcall([this, policy] { pimpl_->set_sharing_policy(policy); }); return this; @@ -113,6 +123,12 @@ void Link::set_host_wifi_rate(const s4u::Host* host, int level) const wlink->set_host_rate(host, level); } +Link* Link::set_concurrency_limit(int limit) +{ + kernel::actor::simcall([this, limit] { pimpl_->set_concurrency_limit(limit); }); + return this; +} + double Link::get_usage() const { return this->pimpl_->get_constraint()->get_usage(); @@ -179,6 +195,25 @@ Link* Link::set_properties(const std::unordered_map& p return this; } +Link* SplitDuplexLink::get_link_up() const +{ + const auto* pimpl = dynamic_cast(pimpl_); + xbt_assert(pimpl, "Requesting link_up from a non split-duplex link: %s", get_cname()); + return pimpl->get_link_up(); +} + +Link* SplitDuplexLink::get_link_down() const +{ + const auto* pimpl = dynamic_cast(pimpl_); + xbt_assert(pimpl, "Requesting link_down from a non split-duplex link: %s", get_cname()); + return pimpl->get_link_down(); +} + +SplitDuplexLink* SplitDuplexLink::by_name(const std::string& name) +{ + return Engine::get_instance()->split_duplex_link_by_name(name); +} + } // namespace s4u } // namespace simgrid