From bbb37ae9273e9caa5c490db1a2040d2eec139ef2 Mon Sep 17 00:00:00 2001 From: Florian Schmaus <flow@cs.fau.de> Date: Thu, 3 Aug 2017 10:41:30 +0200 Subject: [PATCH] Runtime: Use currentRuntime instead of lastRuntime --- emper/Runtime.cpp | 10 +++------- emper/Runtime.hpp | 7 +++++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/emper/Runtime.cpp b/emper/Runtime.cpp index 44ad44c0..a4106e9b 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 8e850865..5b443b3e 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(); -- GitLab