Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
tracking works better if signals are triggered
[simgrid.git] / src / kernel / activity / ExecImpl.cpp
index 5ecdf6a..0484cc7 100644 (file)
@@ -43,14 +43,11 @@ void simgrid::kernel::activity::ExecImpl::resume()
 
 double simgrid::kernel::activity::ExecImpl::remains()
 {
-  if (host_ == nullptr) // parallel task: their remain is not in flops (we'd need a vector to express it this way
-                        // instead of a scalar), but between 0 and 1
-    throw new std::logic_error(
-        "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().");
-  else // sequential task: everything's fine
-    return surfAction_->getRemains();
+  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?");
+
+  return surfAction_ ? surfAction_->getRemains() : 0;
 }
 double simgrid::kernel::activity::ExecImpl::remainingRatio()
 {
@@ -84,7 +81,14 @@ void simgrid::kernel::activity::ExecImpl::post()
     timeoutDetector = nullptr;
   }
 
+  onCompletion(this);
   /* If there are simcalls associated with the synchro, then answer them */
   if (not simcalls.empty())
     SIMIX_execution_finish(this);
 }
+
+/*************
+ * Callbacks *
+ *************/
+simgrid::xbt::signal<void(simgrid::kernel::activity::ExecImplPtr)> simgrid::kernel::activity::ExecImpl::onCreation;
+simgrid::xbt::signal<void(simgrid::kernel::activity::ExecImplPtr)> simgrid::kernel::activity::ExecImpl::onCompletion;