1 /* Copyright (c) 2013-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "src/kernel/resource/SplitDuplexLinkImpl.hpp"
8 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
14 namespace simgrid::kernel::resource {
16 SplitDuplexLinkImpl::SplitDuplexLinkImpl(const std::string& name, StandardLinkImpl* link_up,
17 StandardLinkImpl* link_down)
18 : LinkImpl(name), piface_(this), link_up_(link_up), link_down_(link_down)
22 bool SplitDuplexLinkImpl::is_used() const
24 return link_up_->is_used() || link_down_->is_used();
27 void SplitDuplexLinkImpl::set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb)
29 xbt_assert(policy != s4u::Link::SharingPolicy::SPLITDUPLEX && policy != s4u::Link::SharingPolicy::WIFI,
30 "Invalid sharing policy for split-duplex links");
31 link_up_->set_sharing_policy(policy, cb);
32 link_down_->set_sharing_policy(policy, cb);
35 void SplitDuplexLinkImpl::set_bandwidth(double value)
37 link_up_->set_bandwidth(value);
38 link_down_->set_bandwidth(value);
41 void SplitDuplexLinkImpl::set_latency(double value)
43 link_up_->set_latency(value);
44 link_down_->set_latency(value);
47 void SplitDuplexLinkImpl::turn_on()
50 link_down_->turn_on();
53 void SplitDuplexLinkImpl::turn_off()
56 link_down_->turn_off();
59 void SplitDuplexLinkImpl::apply_event(profile::Event* event, double value)
61 link_up_->apply_event(event, value);
62 link_down_->apply_event(event, value);
65 void SplitDuplexLinkImpl::seal()
76 void SplitDuplexLinkImpl::set_bandwidth_profile(profile::Profile* profile)
78 link_up_->set_bandwidth_profile(profile);
79 link_down_->set_bandwidth_profile(profile);
82 void SplitDuplexLinkImpl::set_latency_profile(profile::Profile* profile)
84 link_up_->set_latency_profile(profile);
85 link_down_->set_latency_profile(profile);
88 int SplitDuplexLinkImpl::get_concurrency_limit() const
90 return link_up_->get_concurrency_limit();
93 void SplitDuplexLinkImpl::set_concurrency_limit(int limit) const
95 link_up_->set_concurrency_limit(limit);
96 link_down_->set_concurrency_limit(limit);
99 } // namespace simgrid::kernel::resource