From a71989a120236410d9075a19f530ae96de37c5df Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 24 Nov 2020 10:07:51 +0100 Subject: [PATCH] Revert "Make simgrid::xbt::action_fs a std::unique_ptr." This reverts commit cb0572c871501a8dab8e7ad5a833bb372b743d01. It's a bit too cumbersome. --- examples/s4u/replay-comm/s4u-replay-comm.cpp | 8 ++++++-- examples/s4u/replay-io/s4u-replay-io.cpp | 7 ++++++- include/xbt/replay.hpp | 3 +-- src/xbt/xbt_replay.cpp | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/examples/s4u/replay-comm/s4u-replay-comm.cpp b/examples/s4u/replay-comm/s4u-replay-comm.cpp index cb33f3f46b..5d3a4305e9 100644 --- a/examples/s4u/replay-comm/s4u-replay-comm.cpp +++ b/examples/s4u/replay-comm/s4u-replay-comm.cpp @@ -8,7 +8,6 @@ #include "xbt/str.h" #include #include -#include #include 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(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; diff --git a/examples/s4u/replay-io/s4u-replay-io.cpp b/examples/s4u/replay-io/s4u-replay-io.cpp index ddf14576fb..9b752dcc02 100644 --- a/examples/s4u/replay-io/s4u-replay-io.cpp +++ b/examples/s4u/replay-io/s4u-replay-io.cpp @@ -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(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; diff --git a/include/xbt/replay.hpp b/include/xbt/replay.hpp index 94ce2e061a..d1596e5a5f 100644 --- a/include/xbt/replay.hpp +++ b/include/xbt/replay.hpp @@ -12,7 +12,6 @@ #include #include -#include #include #include @@ -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; -XBT_PUBLIC_DATA std::unique_ptr action_fs; +XBT_PUBLIC_DATA std::ifstream* action_fs; XBT_PUBLIC int replay_runner(const char* actor_name, const char* trace_filename); } } diff --git a/src/xbt/xbt_replay.cpp b/src/xbt/xbt_replay.cpp index 254de60657..c75acf1028 100644 --- a/src/xbt/xbt_replay.cpp +++ b/src/xbt/xbt_replay.cpp @@ -14,7 +14,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(replay,xbt,"Replay trace reader"); namespace simgrid { namespace xbt { -std::unique_ptr action_fs = nullptr; +std::ifstream* action_fs = nullptr; std::unordered_map action_funs; static std::unordered_map*> action_queues; -- 2.20.1