From: Martin Quinson Date: Thu, 16 Feb 2017 00:50:32 +0000 (+0100) Subject: actually, there is no need for the MsgActor to remember about its host. Its s4u compo... X-Git-Tag: v3_15~359 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/45bde247c800e1904407ae56a2a450e46141bee4 actually, there is no need for the MsgActor to remember about its host. Its s4u component already knows it --- diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index f6e2c8e8fa..d9af33ec1e 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -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(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(SIMIX_process_self_get_data()))->host_; + t_simdata->source = MSG_host_self(); t_simdata->setUsed(); diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index b0aea86a18..3a67a8159c 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -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 */ }; diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index aaefa595a6..253e084288 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -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