#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"
return Engine::get_instance()->link_by_name(name);
}
+kernel::resource::LinkImpl* Link::get_impl() const
+{
+ xbt_assert(
+ get_sharing_policy() != SharingPolicy::SPLITDUPLEX,
+ "Impossible to get a LinkImpl* from a Split-Duplex link. You should call this method to each UP/DOWN member");
+ return dynamic_cast<kernel::resource::LinkImpl*>(pimpl_);
+}
+
Link* Link::by_name_or_null(const std::string& name)
{
return Engine::get_instance()->link_by_name_or_null(name);
{
double d_value = 0.0;
try {
- d_value = xbt_parse_get_time("", 0, value.c_str(), nullptr, "");
+ d_value = xbt_parse_get_time("", 0, value, "");
} catch (const simgrid::ParseError&) {
throw std::invalid_argument(std::string("Impossible to set latency for link: ") + get_name() +
std::string(". Invalid value: ") + value);
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(". Use NetZone::create_split_duplex_link."));
+
kernel::actor::simcall([this, policy] { pimpl_->set_sharing_policy(policy); });
return this;
}
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();
{
kernel::actor::simcall([this]() { this->pimpl_->turn_off(); });
}
-void Link::seal()
+Link* Link::seal()
{
kernel::actor::simcall([this]() { this->pimpl_->seal(); });
+ return this;
}
bool Link::is_on() const
return this;
}
+Link* SplitDuplexLink::get_link_up() const
+{
+ return dynamic_cast<kernel::resource::SplitDuplexLinkImpl*>(pimpl_)->get_link_up();
+}
+
+Link* SplitDuplexLink::get_link_down() const
+{
+ return dynamic_cast<kernel::resource::SplitDuplexLinkImpl*>(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
sg_link_set_data(link, data);
}
-int sg_link_count()
+size_t sg_link_count()
{
return simgrid::s4u::Engine::get_instance()->get_link_count();
}
{
std::vector<simgrid::s4u::Link*> links = simgrid::s4u::Engine::get_instance()->get_all_links();
- sg_link_t* res = xbt_new(sg_link_t, links.size());
- memcpy(res, links.data(), sizeof(sg_link_t) * links.size());
+ auto* res = xbt_new(sg_link_t, links.size());
+ std::copy(begin(links), end(links), res);
return res;
}