Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use Mailbox::get_unique<>(), and save a few delete.
[simgrid.git] / examples / s4u / trace-masterworkers / s4u-trace-masterworkers.cpp
index d0013cd..d55098d 100644 (file)
@@ -59,9 +59,8 @@ static void worker(std::vector<std::string> args)
   TRACE_host_variable_set(my_hostname, "task_computation", 0);
 
   while (true) {
-    const auto* task = static_cast<Task*>(mailbox->get());
+    auto task = mailbox->get_unique<Task>();
     if (task->name == "finalize") {
-      delete task;
       break;
     }
     // adding the task's cost to the variable "task_computation"
@@ -70,7 +69,6 @@ static void worker(std::vector<std::string> args)
         ->set_name(task->name)
         ->set_tracing_category(task->category)
         ->wait();
-    delete task;
   }
 
   XBT_DEBUG("Exiting now.");