X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4d02714ee138a3bd9b02e0064b7a2aa26407e9e8..93e69b9ab0e7438d21068ff90309f83537d17f72:/src/msg/msg_task.cpp diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index 3695cc0436..49a1b17066 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -67,17 +67,22 @@ msg_error_t Task::execute() xbt_assert(std::isfinite(flops_amount), "flops_amount is not finite!"); msg_error_t status = MSG_OK; + if (flops_amount <= 0.0) + return MSG_OK; - set_used(); try { - s4u::ExecPtr e = s4u::this_actor::exec_init(flops_amount) - ->set_priority(1 / priority_) - ->set_bound(bound_) - ->set_tracing_category(tracing_category_) - ->start(); - compute = boost::static_pointer_cast(e->get_impl()); - - e->wait(); + set_used(); + if (parallel_) + compute = s4u::this_actor::exec_init(hosts_, flops_parallel_amount, bytes_parallel_amount); + else + compute = s4u::this_actor::exec_init(flops_amount); + + compute->set_name(name_) + ->set_tracing_category(tracing_category_) + ->set_timeout(timeout_) + ->set_priority(1 / priority_) + ->set_bound(bound_) + ->wait(); set_not_used(); XBT_DEBUG("Execution task '%s' finished", get_cname()); @@ -280,6 +285,25 @@ msg_error_t MSG_task_execute(msg_task_t task) { return task->execute(); } + +/** + * @brief Executes a parallel task and waits for its termination. + * + * @param task a #msg_task_t to execute on the location on which the process is running. + * + * @return #MSG_OK if the task was successfully completed, #MSG_TASK_CANCELED or #MSG_HOST_FAILURE otherwise + */ +msg_error_t MSG_parallel_task_execute(msg_task_t task) +{ + return task->execute(); +} + +msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeout) +{ + task->set_timeout(timeout); + return task->execute(); +} + /** * @brief Sends a task on a mailbox. *