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 3e189aa..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.");
@@ -99,7 +97,7 @@ int main(int argc, char* argv[])
   TRACE_category_with_color("finalize", "0 1 0"); // finalize is green
   // categories without user-defined colors receive random colors generated by the tracing system
   TRACE_category("request");
-  TRACE_category_with_color("report", NULL);
+  TRACE_category_with_color("report", nullptr);
 
   e.register_function("master", &master);
   e.register_function("worker", &worker);