X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d21feacc9eab1017d4e5b9d989a5c68c89d1f47c..7d06231bf31deb78e97d5f2408e300c0e4f55af1:/src/msg/msg_task.cpp diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index 42ec522c5a..c55ae4f6b3 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -12,7 +12,24 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)"); -void s_simdata_task_t::report_multiple_use() const +namespace simgrid { +namespace msg { +Task::~Task() +{ + /* parallel tasks only */ + delete[] host_list; + delete[] flops_parallel_amount; + delete[] bytes_parallel_amount; +} + +void Task::set_used() +{ + if (this->is_used) + this->report_multiple_use(); + this->is_used = true; +} + +void Task::report_multiple_use() const { if (msg_global->debug_multiple_use){ XBT_ERROR("This task is already used in there:"); @@ -25,6 +42,8 @@ void s_simdata_task_t::report_multiple_use() const "(use --cfg=msg/debug-multiple-use:on to get the backtrace of the other process)"); } } +} // namespace msg +} // namespace simgrid /********************************* Task **************************************/ /** @brief Creates a new task @@ -45,17 +64,12 @@ msg_task_t MSG_task_create(const char *name, double flop_amount, double message_ static std::atomic_ullong counter{0}; msg_task_t task = new s_msg_task_t; - simdata_task_t simdata = new s_simdata_task_t(); - task->simdata = simdata; + /* Simulator Data */ + task->simdata = new simgrid::msg::Task(name ? name : "", flop_amount, message_size); /* Task structure */ - task->name = xbt_strdup(name); task->data = data; - /* Simulator Data */ - simdata->bytes_amount = message_size; - simdata->flops_amount = flop_amount; - task->counter = counter++; task->category = nullptr; @@ -149,13 +163,13 @@ msg_host_t MSG_task_get_source(msg_task_t task) /** @brief Returns the name of the given task. */ const char *MSG_task_get_name(msg_task_t task) { - return task->name; + return task->simdata->get_cname(); } /** @brief Sets the name of the given task. */ void MSG_task_set_name(msg_task_t task, const char *name) { - task->name = xbt_strdup(name); + task->simdata->set_name(name); } /** @brief Destroys the given task. @@ -176,7 +190,6 @@ msg_error_t MSG_task_destroy(msg_task_t task) } xbt_free(task->category); - xbt_free(task->name); /* free main structures */ delete task->simdata;