+#ifdef HAVE_TRACING
+ TRACE_msg_task_get_start();
+ double start_time = MSG_get_clock();
+#endif
+
+ /* Sanity check */
+ xbt_assert(task, "Null pointer for the task storage");
+
+ if (*task)
+ XBT_WARN
+ ("Asked to write the received task in a non empty struct -- proceeding.");
+
+ /* Try to receive it by calling SIMIX network layer */
+ TRY {
+ simcall_comm_recv_bounded(mailbox, task, NULL, NULL, NULL, timeout, rate);
+ XBT_DEBUG("Got task %s from %p",(*task)->name,mailbox);
+ (*task)->simdata->isused=0;
+ }
+ CATCH(e) {
+ switch (e.category) {
+ case cancel_error:
+ ret = MSG_HOST_FAILURE;
+ break;
+ case network_error:
+ ret = MSG_TRANSFER_FAILURE;
+ break;
+ case timeout_error:
+ ret = MSG_TIMEOUT;
+ break;
+ default:
+ RETHROW;
+ }
+ xbt_ex_free(e);
+ }
+
+#ifdef HAVE_TRACING
+ if (ret != MSG_HOST_FAILURE &&
+ ret != MSG_TRANSFER_FAILURE &&
+ ret != MSG_TIMEOUT) {
+ TRACE_msg_task_get_end(start_time, *task);
+ }
+#endif
+ MSG_RETURN(ret);
+}