1 /* Copyright (c) 2004-2022. 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 #ifndef SIMGRID_KERNEL_RESOURCE_STANDARDLINKIMPL_HPP
7 #define SIMGRID_KERNEL_RESOURCE_STANDARDLINKIMPL_HPP
9 #include "src/kernel/resource/LinkImpl.hpp"
21 class StandardLinkImpl : public LinkImpl {
23 s4u::Link::SharingPolicy sharing_policy_ = s4u::Link::SharingPolicy::SHARED;
26 explicit StandardLinkImpl(const std::string& name);
27 StandardLinkImpl(const StandardLinkImpl&) = delete;
28 StandardLinkImpl& operator=(const StandardLinkImpl&) = delete;
29 ~StandardLinkImpl() override = default; // Use destroy() instead of this destructor.
31 Metric latency_ = {0.0, 1, nullptr};
32 Metric bandwidth_ = {1.0, 1, nullptr};
35 void destroy(); // Must be called instead of the destructor
37 void latency_check(double latency) const;
39 /** @brief Public interface */
40 const s4u::Link* get_iface() const { return &piface_; }
41 s4u::Link* get_iface() { return &piface_; }
43 /** @brief Get the bandwidth in bytes per second of current Link */
44 double get_bandwidth() const override { return bandwidth_.peak * bandwidth_.scale; }
46 /** @brief Get the latency in seconds of current Link */
47 double get_latency() const override { return latency_.peak * latency_.scale; }
49 /** @brief The sharing policy */
50 void set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb) override;
51 s4u::Link::SharingPolicy get_sharing_policy() const override { return sharing_policy_; }
53 void turn_on() override;
54 void turn_off() override;
58 void on_bandwidth_change() const;
60 /* setup the profile file with bandwidth events (peak speed changes due to external load).
61 * Profile must contain percentages (value between 0 and 1). */
62 void set_bandwidth_profile(kernel::profile::Profile* profile) override;
63 /* setup the profile file with latency events (peak latency changes due to external load).
64 * Profile must contain absolute values */
65 void set_latency_profile(kernel::profile::Profile* profile) override;
67 void set_concurrency_limit(int limit) const override;
70 } // namespace resource
72 } // namespace simgrid
74 #endif /* SIMGRID_KERNEL_RESOURCE_STANDARDLINKIMPL_HPP */