From: Arnaud Giersch Date: Fri, 1 Jun 2018 12:37:21 +0000 (+0200) Subject: Define Actor::on_exit() taking a std::function. X-Git-Tag: v3.20~176 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d83d72cf525e150c93da31fd378922c2f370b3a3?hp=bd09ae420315e4fb0d9e20749c575d17c218e5de Define Actor::on_exit() taking a std::function. --- diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 6d6c6d8e36..5ed31955b5 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -6,6 +6,7 @@ #ifndef SIMGRID_S4U_ACTOR_HPP #define SIMGRID_S4U_ACTOR_HPP +#include #include #include #include @@ -237,6 +238,7 @@ public: * executed when your actor is killed. You should use them to free the data used by your actor. */ void on_exit(int_f_pvoid_pvoid_t fun, void* data); + void on_exit(std::function fun, void* data); /** Sets the time at which that actor should be killed */ void set_kill_time(double time); @@ -408,6 +410,7 @@ XBT_PUBLIC void kill(); /** @brief Add a function to the list of "on_exit" functions. */ XBT_PUBLIC void on_exit(int_f_pvoid_pvoid_t fun, void* data); +XBT_PUBLIC void on_exit(std::function fun, void* data); /** @brief Migrate the actor to a new host. */ XBT_PUBLIC void migrate(Host* new_host); diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 31746fcca3..bd5b149538 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -79,6 +79,11 @@ void Actor::on_exit(int_f_pvoid_pvoid_t fun, void* data) simgrid::simix::simcall([this, fun, data] { SIMIX_process_on_exit(pimpl_, fun, data); }); } +void Actor::on_exit(std::function fun, void* data) +{ + simgrid::simix::simcall([this, fun, data] { SIMIX_process_on_exit(pimpl_, fun, data); }); +} + /** @brief Moves the actor to another host * * If the actor is currently blocked on an execution activity, the activity is also @@ -371,6 +376,11 @@ void on_exit(int_f_pvoid_pvoid_t fun, void* data) SIMIX_process_self()->iface()->on_exit(fun, data); } +void on_exit(std::function fun, void* data) +{ + SIMIX_process_self()->iface()->on_exit(fun, data); +} + /** @brief Moves the current actor to another host * * @see simgrid::s4u::Actor::migrate() for more information