Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make piface_ private and have get_iface() everywhere
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 13 Nov 2019 12:22:12 +0000 (13:22 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 13 Nov 2019 12:22:12 +0000 (13:22 +0100)
src/kernel/resource/DiskImpl.hpp
src/plugins/link_energy.cpp
src/s4u/s4u_Host.cpp
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/StorageImpl.hpp
src/surf/network_cm02.cpp
src/surf/network_interface.hpp
src/surf/network_wifi.cpp
src/surf/ptask_L07.cpp
src/surf/storage_n11.cpp

index 80ae7a6..c25b0a2 100644 (file)
@@ -50,6 +50,7 @@ public:
 class DiskImpl : public Resource, public surf::PropertyHolder {
   bool currently_destroying_ = false;
   s4u::Host* host_           = nullptr;
+  s4u::Disk piface_;
 
 public:
   DiskImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double read_bw, double bwrite_bw);
@@ -59,7 +60,6 @@ public:
   ~DiskImpl() override;
 
   /** @brief Public interface */
-  s4u::Disk piface_;
   s4u::Disk* get_iface() { return &piface_; }
   /** @brief Check if the Storage is used (if an action currently uses its resources) */
   bool is_used() override;
index 01b0bab..18c8ae1 100644 (file)
@@ -159,7 +159,7 @@ static void on_communicate(simgrid::kernel::resource::NetworkAction const& actio
       continue;
 
     XBT_DEBUG("Update link %s", link->get_cname());
-    LinkEnergy* link_energy = link->piface_.extension<LinkEnergy>();
+    LinkEnergy* link_energy = link->get_iface()->extension<LinkEnergy>();
     link_energy->init_watts_range_list();
     link_energy->update();
   }
@@ -211,7 +211,7 @@ void sg_link_energy_plugin_init()
       simgrid::kernel::resource::NetworkAction const& action, simgrid::kernel::resource::Action::State /* previous */) {
     for (simgrid::kernel::resource::LinkImpl* link : action.links()) {
       if (link != nullptr)
-        link->piface_.extension<LinkEnergy>()->update();
+        link->get_iface()->extension<LinkEnergy>()->update();
     }
   });
 
index 71710c4..c2e0169 100644 (file)
@@ -154,7 +154,7 @@ void Host::route_to(Host* dest, std::vector<Link*>& links, double* latency)
   std::vector<kernel::resource::LinkImpl*> linkImpls;
   this->route_to(dest, linkImpls, latency);
   for (kernel::resource::LinkImpl* const& l : linkImpls)
-    links.push_back(&l->piface_);
+    links.push_back(l->get_iface());
 }
 
 /** @brief Just like Host::routeTo, but filling an array of link implementations */
@@ -311,7 +311,7 @@ std::unordered_map<std::string, Storage*> const& Host::get_mounted_storages()
   if (mounts_ == nullptr) {
     mounts_ = new std::unordered_map<std::string, Storage*>();
     for (auto const& m : this->pimpl_->storage_) {
-      mounts_->insert({m.first, &m.second->piface_});
+      mounts_->insert({m.first, m.second->get_iface()});
     }
   }
   return *mounts_;
index d2f6a48..86b966d 100644 (file)
@@ -153,7 +153,7 @@ std::vector<s4u::Disk*> HostImpl::get_disks()
 {
   std::vector<s4u::Disk*> disks;
   for (auto const& d : disks_)
-    disks.push_back(&d->piface_);
+    disks.push_back(d->get_iface());
   return disks;
 }
 
@@ -179,7 +179,7 @@ std::vector<const char*> HostImpl::get_attached_storages()
   std::vector<const char*> storages;
   for (auto const& s : storage_)
     if (s.second->get_host() == piface_->get_cname())
-      storages.push_back(s.second->piface_.get_cname());
+      storages.push_back(s.second->get_iface()->get_cname());
   return storages;
 }
 
index fed3f37..3de2ae6 100644 (file)
@@ -44,6 +44,7 @@ public:
  */
 class XBT_PRIVATE HostImpl : public simgrid::surf::PropertyHolder {
   std::vector<kernel::actor::ProcessArg*> actors_at_boot_;
+  s4u::Host* piface_ = nullptr; // FIXME: why don't we store a s4u::Host here as we do everywhere else?
 
 public:
   friend simgrid::vm::VirtualMachineImpl;
@@ -60,7 +61,7 @@ public:
   std::map<std::string, kernel::resource::StorageImpl*> storage_;
   std::vector<kernel::resource::DiskImpl*> disks_;
 
-  s4u::Host* piface_ = nullptr;
+  s4u::Host* get_iface() { return piface_; }
 
   void turn_on();
   void turn_off(kernel::actor::ActorImpl* issuer);
index 3590cae..bd885d0 100644 (file)
@@ -60,6 +60,8 @@ public:
  * @details A Storage represent a storage unit (e.g.: hard drive, usb key)
  */
 class StorageImpl : public Resource, public surf::PropertyHolder {
+  s4u::Storage piface_;
+
 public:
   /** @brief Storage constructor */
   StorageImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double bread, double bwrite,
@@ -69,9 +71,7 @@ public:
 
   ~StorageImpl() override;
 
-  /** @brief Public interface */
-  s4u::Storage piface_;
-
+  s4u::Storage* get_iface() { return &piface_; }
   /** @brief Check if the Storage is used (if an action currently uses its resources) */
   bool is_used() override;
 
index 697e36a..c8f084c 100644 (file)
@@ -306,7 +306,7 @@ NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& nam
   if (policy == s4u::Link::SharingPolicy::FATPIPE)
     get_constraint()->unshare();
 
-  simgrid::s4u::Link::on_creation(this->piface_);
+  simgrid::s4u::Link::on_creation(*get_iface());
 }
 
 void NetworkCm02Link::apply_event(kernel::profile::Event* triggered, double value)
index ea9039e..d5ecd17 100644 (file)
@@ -109,6 +109,7 @@ public:
  */
 class LinkImpl : public Resource, public surf::PropertyHolder {
   bool currently_destroying_ = false;
+  s4u::Link piface_;
 
 protected:
   LinkImpl(NetworkModel* model, const std::string& name, lmm::Constraint* constraint);
@@ -120,7 +121,7 @@ public:
   void destroy(); // Must be called instead of the destructor
 
   /** @brief Public interface */
-  s4u::Link piface_;
+  s4u::Link* get_iface() { return &piface_; }
 
   /** @brief Get the bandwidth in bytes per second of current Link */
   virtual double get_bandwidth();
index 10eb70b..f7b761f 100644 (file)
@@ -24,7 +24,7 @@ NetworkWifiLink::NetworkWifiLink(NetworkCm02Model* model, const std::string& nam
   for (auto bandwidth : bandwidths)
     bandwidths_.push_back({bandwidth, 1.0, nullptr});
 
-  simgrid::s4u::Link::on_creation(this->piface_);
+  simgrid::s4u::Link::on_creation(*get_iface());
 }
 
 void NetworkWifiLink::set_host_rate(s4u::Host* host, int rate_level)
index 260757a..3b1ca2e 100644 (file)
@@ -254,7 +254,7 @@ LinkL07::LinkL07(NetworkL07Model* model, const std::string& name, double bandwid
   if (policy == s4u::Link::SharingPolicy::FATPIPE)
     get_constraint()->unshare();
 
-  s4u::Link::on_creation(this->piface_);
+  s4u::Link::on_creation(*get_iface());
 }
 
 kernel::resource::CpuAction* CpuL07::execution_start(double size)
index 22246c5..90a77b4 100644 (file)
@@ -96,7 +96,7 @@ StorageN11::StorageN11(StorageModel* model, const std::string& name, lmm::System
     : StorageImpl(model, name, maxminSystem, bread, bwrite, type_id, content_name, size, attach)
 {
   XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size);
-  s4u::Storage::on_creation(this->piface_);
+  s4u::Storage::on_creation(*get_iface());
 }
 
 StorageAction* StorageN11::io_start(sg_size_t size, s4u::Io::OpType type)