Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Register ExecImpls with ActorImpl.
[simgrid.git] / src / msg / msg_legacy.cpp
index 505ea3b..6ddae74 100644 (file)
@@ -27,8 +27,10 @@ msg_error_t MSG_main()
 }
 void MSG_function_register(const char* name, int (*code)(int, char**))
 {
-  simgrid::s4u::Engine::get_instance()->register_function(
-      name, [code](std::vector<std::string> args) { return simgrid::xbt::wrap_main(code, std::move(args)); });
+  simgrid::kernel::actor::ActorCodeFactory code_factory = [code](std::vector<std::string> args) {
+    return simgrid::xbt::wrap_main(code, std::move(args));
+  };
+  simgrid::s4u::Engine::get_instance()->register_function(name, code_factory);
 }
 void MSG_function_register_default(int (*code)(int, char**))
 {
@@ -299,7 +301,15 @@ sg_size_t MSG_storage_write(sg_storage_t storage, sg_size_t size)
 /* ************************** hosts *************************** */
 xbt_dynar_t MSG_hosts_as_dynar()
 {
-  return sg_hosts_as_dynar();
+  size_t host_count = sg_host_count();
+  sg_host_t* list   = sg_host_list();
+
+  xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), nullptr);
+  for (size_t i = 0; i < host_count; i++)
+    xbt_dynar_push_as(res, sg_host_t, list[i]);
+  xbt_free(list);
+
+  return res;
 }
 size_t MSG_get_host_number()
 {