Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more sg_exec functions
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sat, 7 Mar 2020 13:26:16 +0000 (14:26 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sat, 7 Mar 2020 13:33:14 +0000 (14:33 +0100)
include/simgrid/exec.h
src/s4u/s4u_Exec.cpp

index b74cfad..4dee58a 100644 (file)
@@ -13,6 +13,8 @@
 SG_BEGIN_DECL
 
 XBT_PUBLIC void sg_exec_set_bound(sg_exec_t exec, double bound);
+XBT_PUBLIC const char* sg_exec_get_name(sg_exec_t exec);
+XBT_PUBLIC void sg_exec_set_name(sg_exec_t exec, const char* name);
 XBT_PUBLIC void sg_exec_set_host(sg_exec_t exec, sg_host_t new_host);
 XBT_PUBLIC double sg_exec_get_remaining(const_sg_exec_t exec);
 XBT_PUBLIC double sg_exec_get_remaining_ratio(const_sg_exec_t exec);
@@ -22,6 +24,8 @@ XBT_PUBLIC void sg_exec_cancel(sg_exec_t exec);
 XBT_PUBLIC int sg_exec_test(sg_exec_t exec);
 XBT_PUBLIC sg_error_t sg_exec_wait(sg_exec_t exec);
 XBT_PUBLIC sg_error_t sg_exec_wait_for(sg_exec_t exec, double timeout);
+XBT_PUBLIC int sg_exec_wait_any_for(sg_exec_t* execs, size_t count, double timeout);
+XBT_PUBLIC int sg_exec_wait_any(sg_exec_t* execs, size_t count);
 
 SG_END_DECL
 
index ba688e4..86926f8 100644 (file)
@@ -217,6 +217,16 @@ void sg_exec_set_bound(sg_exec_t exec, double bound)
   exec->set_bound(bound);
 }
 
+const char* sg_exec_get_name(sg_exec_t exec)
+{
+  return exec->get_cname();
+}
+
+void sg_exec_set_name(sg_exec_t exec, const char* name)
+{
+  exec->set_name(name);
+}
+
 void sg_exec_set_host(sg_exec_t exec, sg_host_t new_host)
 {
   exec->set_host(new_host);
@@ -283,3 +293,24 @@ sg_error_t sg_exec_wait_for(sg_exec_t exec, double timeout)
   exec->unref();
   return status;
 }
+
+int sg_exec_wait_any(sg_exec_t* execs, size_t count)
+{
+  return sg_exec_wait_any_for(execs, count, -1);
+}
+
+int sg_exec_wait_any_for(sg_exec_t* execs, size_t count, double timeout)
+{
+  std::vector<simgrid::s4u::ExecPtr> s4u_execs;
+  for (unsigned int i = 0; i < count; i++) {
+    s4u_execs.emplace_back(execs[i]);
+  }
+  int pos = simgrid::s4u::Exec::wait_any_for(&s4u_execs, timeout);
+  if (pos != -1)
+    s4u_execs[pos]->unref();
+  else
+    for (const auto& e : s4u_execs)
+      e->unref();
+
+  return pos;
+}