Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename smx_process to ActorImpl
[simgrid.git] / src / msg / msg_process.cpp
index 28c596e..cf77537 100644 (file)
@@ -10,7 +10,7 @@
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 #include "xbt/functional.hpp"
-#include "src/simix/smx_process_private.h"
+#include "src/simix/ActorImpl.hpp"
 #include "src/simix/smx_private.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_process, msg, "Logging specific to MSG (process)");
@@ -132,10 +132,11 @@ msg_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_
 msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_func_t code, void *data, msg_host_t host,
                                                   int argc, char **argv, xbt_dict_t properties)
 {
+  std::function<void()> function;
+  if (code)
+    function = simgrid::xbt::wrapMain(code, argc, const_cast<const char*const*>(argv));
   msg_process_t res = MSG_process_create_with_environment(name,
-    code ? simgrid::xbt::wrapMain(code, argc, argv) : std::function<void()>(),
-    data, host,
-    properties);
+    std::move(function), data, host, properties);
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
   xbt_free(argv);
@@ -362,10 +363,9 @@ int MSG_process_get_PID(msg_process_t process)
 {
   /* Do not raise an exception here: this function is called by the logs
    * and the exceptions, so it would be called back again and again */
-  if (process == nullptr) {
+  if (process == nullptr)
     return 0;
-  }
-  return simcall_process_get_PID(process);
+  return process->pid;
 }
 
 /** \ingroup m_process_management
@@ -376,8 +376,7 @@ int MSG_process_get_PID(msg_process_t process)
  */
 int MSG_process_get_PPID(msg_process_t process)
 {
-  xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
-  return simcall_process_get_PPID(process);
+  return process->ppid;
 }
 
 /** \ingroup m_process_management
@@ -387,8 +386,7 @@ int MSG_process_get_PPID(msg_process_t process)
  */
 const char *MSG_process_get_name(msg_process_t process)
 {
-  xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
-  return simcall_process_get_name(process);
+  return process->name.c_str();
 }
 
 /** \ingroup m_process_management
@@ -455,7 +453,7 @@ msg_error_t MSG_process_suspend(msg_process_t process)
 
   TRACE_msg_process_suspend(process);
   simcall_process_suspend(process);
-  MSG_RETURN(MSG_OK);
+  return MSG_OK;
 }
 
 /** \ingroup m_process_management
@@ -469,7 +467,7 @@ msg_error_t MSG_process_resume(msg_process_t process)
 
   TRACE_msg_process_resume(process);
   simcall_process_resume(process);
-  MSG_RETURN(MSG_OK);
+  return MSG_OK;
 }
 
 /** \ingroup m_process_management