From 320d57b79b6f363e6430ec2fffcd3301a52a2ad9 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Thu, 11 Jan 2018 16:19:07 +0100 Subject: [PATCH 1/1] [S4U] Add onCreation signal to the actor API --- ChangeLog | 1 + include/simgrid/s4u/Actor.hpp | 4 ++++ src/simix/ActorImpl.cpp | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8768cc3af0..d6c6d18eee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ SimGrid (3.19) NOT RELEASED YET (target: March 20 2018, 16:15:27 UTC) S4U - Execution->setHost() can be called after start() to migrate it. - Comm::test_any() is now implemented. + - s4u::Actor now has an onCreation() signal. XBT - Remove XBT_LOG_CONNECT, it should be useless nowadays. diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 8f332c81c7..670f5022c9 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -162,6 +163,9 @@ public: /** Retrieve a reference to myself */ static ActorPtr self(); + /** Signal to others that a new actor has been created **/ + static simgrid::xbt::signal onCreation; + /** Create an actor using a function * * If the actor is restarted, the actor has a fresh copy of the function. diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 7866fb050a..fcc6dac696 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -145,6 +145,10 @@ void SIMIX_process_empty_trash() } namespace simgrid { + +namespace s4u { +simgrid::xbt::signal s4u::Actor::onCreation; // TODO cheinrich is this the right location here? +} namespace simix { ActorImpl::~ActorImpl() @@ -310,6 +314,8 @@ smx_actor_t SIMIX_process_create(const char* name, std::function code, v } smx_actor_t process = new simgrid::simix::ActorImpl(); + simgrid::s4u::ActorPtr tmp = process->iface(); // Passing this directly to onCreation will lead to crashes + simgrid::s4u::Actor::onCreation(tmp); xbt_assert(code && host != nullptr, "Invalid parameters"); /* Process data */ -- 2.20.1