Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
s4u::Exec->getRemains() should not fail on terminated activities
[simgrid.git] / src / kernel / activity / ExecImpl.cpp
index 9dba149c180548c775ed493c51eee31c309a7216..6c0cf00c5891a241d174e12792bc7b274e089667 100644 (file)
@@ -43,15 +43,11 @@ void simgrid::kernel::activity::ExecImpl::resume()
 
 double simgrid::kernel::activity::ExecImpl::remains()
 {
-  static std::logic_error e(
-      "The remaining work on parallel tasks cannot be defined as a scalar amount of flops (it's a vector). "
-      "So parallel_task->remains() is not defined. "
-      "You are probably looking for parallel_task->remainingRatio().");
+  xbt_assert(host_ != nullptr, "Calling remains() on a parallel execution is not allowed. "
+                               "We would need to return a vector instead of a scalar. "
+                               "Did you meant remainingRatio() instead?");
 
-  if (host_ == nullptr) // parallel task: their remain is not in flops (we'd need a vector for that, not a scalar)
-    throw &e;
-  else // sequential task: everything's fine
-    return surfAction_->getRemains();
+  return surfAction_ ? surfAction_->getRemains() : 0;
 }
 double simgrid::kernel::activity::ExecImpl::remainingRatio()
 {