Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revert "Make simgrid::xbt::action_fs a std::unique_ptr."
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 24 Nov 2020 09:07:51 +0000 (10:07 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 24 Nov 2020 09:07:51 +0000 (10:07 +0100)
This reverts commit cb0572c871501a8dab8e7ad5a833bb372b743d01.

It's a bit too cumbersome.

examples/s4u/replay-comm/s4u-replay-comm.cpp
examples/s4u/replay-io/s4u-replay-io.cpp
include/xbt/replay.hpp
src/xbt/xbt_replay.cpp

index cb33f3f..5d3a430 100644 (file)
@@ -8,7 +8,6 @@
 #include "xbt/str.h"
 #include <boost/algorithm/string/join.hpp>
 #include <cinttypes>
-#include <memory>
 #include <string>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(replay_comm, "Messages specific for this msg example");
@@ -102,11 +101,16 @@ int main(int argc, char* argv[])
   xbt_replay_action_register("recv", Replayer::recv);
 
   if (argv[3]) {
-    simgrid::xbt::action_fs = std::make_unique<std::ifstream>(argv[3], std::ifstream::in);
+    simgrid::xbt::action_fs = new std::ifstream(argv[3], std::ifstream::in);
   }
 
   e.run();
 
+  if (argv[3]) {
+    delete simgrid::xbt::action_fs;
+    simgrid::xbt::action_fs = nullptr;
+  }
+
   XBT_INFO("Simulation time %g", e.get_clock());
 
   return 0;
index ddf1457..9b752dc 100644 (file)
@@ -115,11 +115,16 @@ int main(int argc, char* argv[])
   xbt_replay_action_register("close", Replayer::close);
 
   if (argv[3]) {
-    simgrid::xbt::action_fs = std::make_unique<std::ifstream>(argv[3], std::ifstream::in);
+    simgrid::xbt::action_fs = new std::ifstream(argv[3], std::ifstream::in);
   }
 
   e.run();
 
+  if (argv[3]) {
+    delete simgrid::xbt::action_fs;
+    simgrid::xbt::action_fs = nullptr;
+  }
+
   XBT_INFO("Simulation time %g", e.get_clock());
 
   return 0;
index 94ce2e0..d1596e5 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <fstream>
 #include <functional>
-#include <memory>
 #include <queue>
 #include <unordered_map>
 
@@ -21,7 +20,7 @@ namespace xbt {
 /* To split the file if a unique one is given (specific variable for the other case live in runner()) */
 using ReplayAction = std::vector<std::string>;
 
-XBT_PUBLIC_DATA std::unique_ptr<std::ifstream> action_fs;
+XBT_PUBLIC_DATA std::ifstream* action_fs;
 XBT_PUBLIC int replay_runner(const char* actor_name, const char* trace_filename);
 }
 }
index 254de60..c75acf1 100644 (file)
@@ -14,7 +14,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(replay,xbt,"Replay trace reader");
 namespace simgrid {
 namespace xbt {
 
-std::unique_ptr<std::ifstream> action_fs = nullptr;
+std::ifstream* action_fs = nullptr;
 std::unordered_map<std::string, action_fun> action_funs;
 static std::unordered_map<std::string, std::queue<ReplayAction*>*> action_queues;