Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
actually, there is no need for the MsgActor to remember about its host. Its s4u compo...
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 16 Feb 2017 00:50:32 +0000 (01:50 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 16 Feb 2017 00:50:32 +0000 (01:50 +0100)
src/msg/msg_gos.cpp
src/msg/msg_private.h
src/msg/msg_process.cpp

index f6e2c8e..d9af33e 100644 (file)
@@ -307,7 +307,7 @@ static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *al
   /* Prepare the task to send */
   t_simdata = task->simdata;
   t_simdata->sender = myself;
-  t_simdata->source = (static_cast<MsgActorExt*>(SIMIX_process_self_get_data()))->host_;
+  t_simdata->source = MSG_host_self();
   t_simdata->setUsed();
   t_simdata->comm = nullptr;
   msg_global->sent_msg++;
@@ -779,7 +779,7 @@ msg_error_t MSG_task_send_with_timeout(msg_task_t task, const char *alias, doubl
   /* Prepare the task to send */
   t_simdata = task->simdata;
   t_simdata->sender = process;
-  t_simdata->source = (static_cast<MsgActorExt*>(SIMIX_process_self_get_data()))->host_;
+  t_simdata->source = MSG_host_self();
 
   t_simdata->setUsed();
 
index b0aea86..3a67a81 100644 (file)
@@ -75,7 +75,6 @@ typedef struct simdata_file {
 
 class MsgActorExt {
 public:
-  msg_host_t host_; /* the host on which the process is running */
   msg_error_t errno_ = MSG_OK;  /* the last value returned by a MSG_function */
   void* data = nullptr; /* user data */
 };
index aaefa59..253e084 100644 (file)
@@ -141,19 +141,17 @@ msg_process_t MSG_process_create_with_environment(
   msg_host_t host, xbt_dict_t properties)
 {
   xbt_assert(code != nullptr && host != nullptr, "Invalid parameters: host and code params must not be nullptr");
-  MsgActorExt* simdata = new MsgActorExt();
+  MsgActorExt* msgExt = new MsgActorExt();
 
   /* Simulator data for MSG */
-  simdata->host_ = host;
-  simdata->data = data;
+  msgExt->data = data;
 
   /* Let's create the process: SIMIX may decide to start it right now,
    * even before returning the flow control to us */
-  msg_process_t process = simcall_process_create(name, std::move(code), simdata, host, -1, properties, 0);
+  msg_process_t process = simcall_process_create(name, std::move(code), msgExt, host, -1, properties, 0);
 
-  if (!process) {
-    /* Undo everything we have just changed */
-    xbt_free(simdata);
+  if (!process) { /* Undo everything */
+    delete msgExt;
     return nullptr;
   }
   else {
@@ -175,7 +173,6 @@ msg_process_t MSG_process_attach(const char *name, void *data, msg_host_t host,
   MsgActorExt* msgExt = new MsgActorExt();
 
   /* Simulator data for MSG */
-  msgExt->host_  = host;
   msgExt->data   = data;
 
   /* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
@@ -226,10 +223,7 @@ msg_error_t MSG_process_join(msg_process_t process, double timeout){
  */
 msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host)
 {
-  MsgActorExt* msgExt = (MsgActorExt*)process->data;
-  msgExt->host_       = host;
-  msg_host_t now      = msgExt->host_;
-  TRACE_msg_process_change_host(process, now, host);
+  TRACE_msg_process_change_host(process, MSG_process_get_host(process), host);
   simcall_process_set_host(process, host);
   return MSG_OK;
 }
@@ -287,14 +281,11 @@ XBT_PUBLIC(void) MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup) {
  */
 msg_host_t MSG_process_get_host(msg_process_t process)
 {
-  MsgActorExt* msgExt;
   if (process == nullptr) {
-    msgExt = (MsgActorExt*)SIMIX_process_self_get_data();
-  }
-  else {
-    msgExt = (MsgActorExt*)process->data;
+    return MSG_process_self()->host;
+  } else {
+    return process->host;
   }
-  return msgExt ? msgExt->host_ : nullptr;
 }
 
 /** \ingroup m_process_management