diff --git a/emper/Runtime.cpp b/emper/Runtime.cpp index 44ad44c0be267ef30c9ef9a64c1641066403a99e..a4106e9b794399904547424bb9a48c46cb449a78 100644 --- a/emper/Runtime.cpp +++ b/emper/Runtime.cpp @@ -16,7 +16,6 @@ std::mutex Runtime::currentRuntimeMutex; Runtime* Runtime::currentRuntime; -Runtime* Runtime::lastRuntime; thread_local unsigned int Runtime::seed; thread_local workerid_t Runtime::workerId; RuntimeStrategy& Runtime::DEFAULT_STRATEGY = WsStrategy::INSTANCE; @@ -38,7 +37,7 @@ Runtime::Runtime(workerid_t workerCount, RuntimeStrategy& strategy) : workerCoun { std::lock_guard<std::mutex> lock(currentRuntimeMutex); if (currentRuntime != nullptr) { - exit(EXIT_FAILURE); + DIE_MSG("There is already a runtime active"); } currentRuntime = this; } @@ -66,7 +65,6 @@ Runtime::Runtime(workerid_t workerCount, RuntimeStrategy& strategy) : workerCoun } #ifdef EMPER_STATS - lastRuntime = this; int res = std::atexit(&printLastRuntimeStats); if (res) { DIE_MSG("could not register printStats() with at_exit()"); @@ -128,9 +126,7 @@ void Runtime::printStats() { } void Runtime::printLastRuntimeStats() { - if (!lastRuntime) - DIE_MSG("lastRuntime not set when invoking pinrtLastRuntimeStats"); - - lastRuntime->printStats(); + assert(currentRuntime); + currentRuntime->printStats(); } diff --git a/emper/Runtime.hpp b/emper/Runtime.hpp index 8e8508650562eaa6a2058d7027be71344020d694..5b443b3ede3c69c59e87dcac59eabf38a2fa3f1d 100644 --- a/emper/Runtime.hpp +++ b/emper/Runtime.hpp @@ -42,7 +42,6 @@ private: static RuntimeStrategy& DEFAULT_STRATEGY; - static Runtime* lastRuntime; static void printLastRuntimeStats(); protected: @@ -105,7 +104,11 @@ public: inline ContextManager& getContextManager() { return contextManager; } - + + inline RuntimeStrategy& getStrategy() { + return strategy; + } + void waitUntilFinished(); void printStats();