+/* This actor tests the ongoing execution until its completion, and don't wait before it's terminated. */
+static void monitor()
+{
+ double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+ XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
+ simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_init(computation_amount);
+ activity->start();
+
+ while (not activity->test()) {
+ XBT_INFO("Remaining amount of flops: %g (%.0f%%)", activity->get_remaining(),
+ 100 * activity->get_remaining_ratio());
+ simgrid::s4u::this_actor::sleep_for(0.3);
+ }
+ activity->wait();
+
+ XBT_INFO("Goodbye now!");
+}
+
+/* This actor cancels the ongoing execution after a while. */
+static void canceller()
+{
+ double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+
+ XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
+ simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_async(computation_amount);
+ simgrid::s4u::this_actor::sleep_for(0.5);
+ XBT_INFO("I changed my mind, cancel!");
+ activity->cancel();
+
+ XBT_INFO("Goodbye now!");
+}
+