Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MSG is a C API and should not throw.
[simgrid.git] / teshsuite / msg / task_destroy_cancel / task_destroy_cancel.cpp
index 0326f56..ed57228 100644 (file)
@@ -1,10 +1,9 @@
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include <xbt/ex.hpp>
+#include "simgrid/Exception.hpp"
 #include "simgrid/msg.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
@@ -32,24 +31,16 @@ static int master(int /*argc*/, char* /*argv*/ [])
   msg_comm_t comm = MSG_task_isend(task, "worker_mailbox");
   XBT_INFO("Canceling task \"%s\" during comm", task->name);
   MSG_task_cancel(task);
-  try {
-    MSG_comm_wait(comm, -1);
-  }
-  catch (xbt_ex& ex) {
+  if (MSG_comm_wait(comm, -1) != MSG_OK)
     MSG_comm_destroy(comm);
-  }
   MSG_task_destroy(task);
 
   task = MSG_task_create("finalize", task_comp_size, task_comm_size, NULL);
   comm = MSG_task_isend(task, "worker_mailbox");
   XBT_INFO("Destroying task \"%s\" during comm", task->name);
   MSG_task_destroy(task);
-  try {
-    MSG_comm_wait(comm, -1);
-  }
-  catch (xbt_ex& ex) {
+  if (MSG_comm_wait(comm, -1) != MSG_OK)
     MSG_comm_destroy(comm);
-  }
 
   task = MSG_task_create("cancel", task_comp_size, task_comm_size, NULL);
   MSG_task_send_with_timeout(task, "worker_mailbox", timeout);
@@ -98,7 +89,7 @@ static int worker(int /*argc*/, char* /*argv*/ [])
     MSG_task_execute(task);
     double end = MSG_get_clock();
     XBT_INFO("Task \"%s\" done in %f (amount %f)", MSG_task_get_name(task), end - start,
-             MSG_task_get_remaining_work_ratio(task));
+             MSG_task_get_flops_amount(task));
 
     MSG_task_destroy(task);
   }