]> AND Public Git Repository - simgrid.git/blobdiff - src/kernel/resource/DiskImpl.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Refactor to reduce cognitive complexity
[simgrid.git] / src / kernel / resource / DiskImpl.cpp
index dc0944946f6044340ee811c9094e65069a9f53f3..e3781ab04c822a5eeb6f41c4ed348692bf7bf92f 100644 (file)
@@ -68,11 +68,6 @@ void DiskImpl::destroy()
   delete this;
 }
 
-bool DiskImpl::is_used() const
-{
-  return get_model()->get_maxmin_system()->constraint_used(get_constraint());
-}
-
 void DiskImpl::turn_on()
 {
   if (not is_on()) {
@@ -113,9 +108,13 @@ void DiskImpl::seal()
 
   xbt_assert(this->get_model(), "Cannot seal Disk (%s) without setting the model first", get_cname());
   lmm::System* maxmin_system = get_model()->get_maxmin_system();
+  /* set readwrite constraint if not configured by user */
+  if (readwrite_bw_ == -1) {
+    readwrite_bw_ = std::max(read_bw_.peak, write_bw_.peak);
+  }
   this->set_read_constraint(maxmin_system->constraint_new(this, read_bw_.peak * read_bw_.scale))
       ->set_write_constraint(maxmin_system->constraint_new(this, write_bw_.peak * write_bw_.scale))
-      ->set_constraint(maxmin_system->constraint_new(this, std::max(read_bw_.peak, write_bw_.peak)));
+      ->set_constraint(maxmin_system->constraint_new(this, readwrite_bw_));
   apply_sharing_policy_cfg();
   XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw_.peak, write_bw_.peak);
   Resource::seal();
@@ -156,6 +155,12 @@ void DiskImpl::apply_sharing_policy_cfg()
                                           sharing_policy_cb_[s4u::Disk::Operation::WRITE]);
 }
 
+void DiskImpl::set_factor_cb(const std::function<s4u::Disk::IoFactorCb>& cb)
+{
+  xbt_assert(not is_sealed(), "Cannot set I/O factor callback in an already sealed disk(%s)", get_cname());
+  factor_cb_ = cb;
+}
+
 /**********
  * Action *
  **********/