Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
More information on actor death in monkey's test case
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 28 Feb 2022 08:14:52 +0000 (09:14 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 28 Feb 2022 08:20:17 +0000 (09:20 +0100)
include/xbt/promise.hpp
src/kernel/context/Context.cpp
src/kernel/context/Context.hpp
teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.cpp

index 074853e..09ac8f0 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2015-2022. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2015-2022. 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. */
index 51dd90b..b20d786 100644 (file)
@@ -141,6 +141,11 @@ void Context::stop()
   this->actor_->cleanup();
 }
 
+void Context::set_wannadie(bool value)
+{
+  XBT_DEBUG("Actor %s gonna die.", actor_->get_cname());
+  iwannadie_ = value;
+}
 AttachContext::~AttachContext() = default;
 
 } // namespace context
index dfba34c..0e315e1 100644 (file)
@@ -66,7 +66,7 @@ public:
   virtual ~Context();
 
   bool wannadie() const { return iwannadie_; }
-  void set_wannadie(bool value = true) { iwannadie_ = value; }
+  void set_wannadie(bool value = true);
   bool is_maestro() const { return is_maestro_; }
   void operator()() const { code_(); }
   bool has_code() const { return static_cast<bool>(code_); }
index a290e52..67a1c10 100644 (file)
@@ -40,6 +40,8 @@ static void master(double comp_size, long comm_size)
 {
   XBT_INFO("Master booting");
   sg4::Actor::self()->daemonize();
+  sg4::this_actor::on_exit(
+      [](bool forcefully) { XBT_INFO("Master dying %s.", forcefully ? "forcefully" : "peacefully"); });
 
   while (true) { // This is a daemon
     xbt_assert(sg4::Engine::get_clock() < cfg_deadline,
@@ -63,6 +65,9 @@ static void master(double comp_size, long comm_size)
 static void worker(int id)
 {
   XBT_INFO("Worker booting");
+  sg4::this_actor::on_exit(
+      [id](bool forcefully) { XBT_INFO("worker %d dying %s.", id, forcefully ? "forcefully" : "peacefully"); });
+
   while (todo > 0) {
     xbt_assert(sg4::Engine::get_clock() < cfg_deadline,
                "Failed to run all tasks in less than %d seconds. Is this an infinite loop?", (int)cfg_deadline);