Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SMPI] Replay: Move callbacks to std::function
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Mon, 26 Mar 2018 14:31:17 +0000 (16:31 +0200)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Wed, 28 Mar 2018 15:33:51 +0000 (17:33 +0200)
examples/smpi/replay/replay.cpp
include/xbt/replay.hpp

index 2ac6850..e101ddd 100644 (file)
@@ -17,7 +17,7 @@ static void action_blah(simgrid::xbt::ReplayAction& args)
 action_fun previous_send;
 static void overriding_send(simgrid::xbt::ReplayAction& args)
 {
-  (*previous_send)(args); // Just call the overriden symbol. That's a toy example.
+  previous_send(args); // Just call the overriden symbol. That's a toy example.
 }
 
 int main(int argc, char* argv[])
index 72f5069..a83d442 100644 (file)
@@ -11,6 +11,7 @@
 #include <xbt/misc.h> /* SG_BEGIN_DECL */
 
 #include <fstream>
+#include <functional>
 #include <queue>
 #include <unordered_map>
 
@@ -25,7 +26,7 @@ XBT_PUBLIC int replay_runner(int argc, char* argv[]);
 }
 }
 
-typedef void (*action_fun)(simgrid::xbt::ReplayAction&);
+typedef std::function<void(simgrid::xbt::ReplayAction&)> action_fun;
 XBT_PUBLIC void xbt_replay_action_register(const char* action_name, action_fun function);
 XBT_PUBLIC action_fun xbt_replay_action_get(const char* action_name);