X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dff9e15c44ab6340d27215957c56fa72fad246a2..d74bb413a4b25a580d7cfc96065b638292a2e679:/src/msg/task.c diff --git a/src/msg/task.c b/src/msg/task.c index 60082dc867..e3bf5c158a 100644 --- a/src/msg/task.c +++ b/src/msg/task.c @@ -72,14 +72,22 @@ m_task_t MSG_task_create(const char *name, double compute_duration, simdata->host_list = NULL; simdata->comp_amount = NULL; simdata->comm_amount = NULL; +#ifdef HAVE_TRACING + TRACE_msg_task_create (task); +#endif return task; } +/** prevent the task from being destroyed too quickly (but also prevent it from being sent). Mainly useful in bindings */ +void MSG_task_ref(m_task_t t) { + t->simdata->refcount++; +} + /** \ingroup m_task_management * \brief Return the user data of a #m_task_t. * - * This functions checks whether \a task is a valid pointer or not and return + * This function checks whether \a task is a valid pointer or not and return the user data associated to \a task if it is possible. */ void *MSG_task_get_data(m_task_t task) @@ -89,6 +97,19 @@ void *MSG_task_get_data(m_task_t task) return (task->data); } +/** \ingroup m_task_management + * \brief Sets the user data of a #m_task_t. + * + * This function allows to associate a new pointer to + the user data associated of \a task. + */ +void MSG_task_set_data(m_task_t task,void *data) +{ + xbt_assert0((task != NULL), "Invalid parameter"); + + task->data = data; +} + /** \ingroup m_task_management * \brief Return the sender of a #m_task_t. * @@ -138,6 +159,9 @@ MSG_error_t MSG_task_destroy(m_task_t task) task->simdata->refcount--; if (task->simdata->refcount > 0) return MSG_OK; +#ifdef HAVE_TRACING + TRACE_msg_task_destroy (task); +#endif if (task->name) free(task->name); @@ -148,9 +172,7 @@ MSG_error_t MSG_task_destroy(m_task_t task) action = task->simdata->compute; if (action) SIMIX_action_destroy(action); - action = task->simdata->comm; - if (action) - SIMIX_action_destroy(action); + /* parallel tasks only */ if (task->simdata->host_list) xbt_free(task->simdata->host_list); @@ -177,11 +199,10 @@ MSG_error_t MSG_task_cancel(m_task_t task) return MSG_OK; } if (task->simdata->comm) { - SIMIX_action_cancel(task->simdata->comm); + SIMIX_communication_cancel(task->simdata->comm); return MSG_OK; } - - return MSG_FATAL; + THROW_IMPOSSIBLE; } /** \ingroup m_task_management @@ -223,7 +244,7 @@ double MSG_task_get_remaining_communication(m_task_t task) xbt_assert0((task != NULL) && (task->simdata != NULL), "Invalid parameter"); - return SIMIX_action_get_remains(task->simdata->comm); + return SIMIX_communication_get_remains(task->simdata->comm); } /** \ingroup m_task_management @@ -256,3 +277,5 @@ void MSG_task_set_priority(m_task_t task, double priority) SIMIX_action_set_priority(task->simdata->compute, task->simdata->priority); } + +