From 24bfbf4652ba5cbe63f11767a1b9fb14e5508c3a Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 1 Aug 2016 20:54:26 +0200 Subject: [PATCH] make SIMIX_context_runall() trivial so that its content can be inlined easily --- src/kernel/context/Context.cpp | 3 +-- src/kernel/context/Context.hpp | 1 - src/kernel/context/ContextBoost.cpp | 2 ++ src/kernel/context/ContextRaw.cpp | 3 +++ src/kernel/context/ContextUnix.cpp | 13 ++++++++----- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/kernel/context/Context.cpp b/src/kernel/context/Context.cpp index fc48824a77..a40fa0c1d4 100644 --- a/src/kernel/context/Context.cpp +++ b/src/kernel/context/Context.cpp @@ -103,8 +103,7 @@ AttachContext::~AttachContext() /** @brief Executes all the processes to run (in parallel if possible). */ void SIMIX_context_runall(void) { - if (!xbt_dynar_is_empty(simix_global->process_to_run)) - simix_global->context_factory->run_all(); + simix_global->context_factory->run_all(); } /** @brief returns the current running context */ diff --git a/src/kernel/context/Context.hpp b/src/kernel/context/Context.hpp index bd4b09517b..45e02236fc 100644 --- a/src/kernel/context/Context.hpp +++ b/src/kernel/context/Context.hpp @@ -44,7 +44,6 @@ namespace kernel { namespace context { class Context; - class ContextFactory; XBT_PUBLIC_CLASS ContextFactory { private: diff --git a/src/kernel/context/ContextBoost.cpp b/src/kernel/context/ContextBoost.cpp index f861f8d1f2..414a476e03 100644 --- a/src/kernel/context/ContextBoost.cpp +++ b/src/kernel/context/ContextBoost.cpp @@ -118,6 +118,8 @@ void BoostContextFactory::run_all() } else #endif { + if (xbt_dynar_is_empty(simix_global->process_to_run)) + return; smx_process_t first_process = xbt_dynar_get_as(simix_global->process_to_run, 0, smx_process_t); BoostContext::process_index_ = 1; diff --git a/src/kernel/context/ContextRaw.cpp b/src/kernel/context/ContextRaw.cpp index 6e13140533..6cbe9f6895 100644 --- a/src/kernel/context/ContextRaw.cpp +++ b/src/kernel/context/ContextRaw.cpp @@ -346,6 +346,9 @@ void RawContextFactory::run_all() void RawContextFactory::run_all_serial() { + if (xbt_dynar_is_empty(simix_global->process_to_run)) + return; + smx_process_t first_process = xbt_dynar_get_as(simix_global->process_to_run, 0, smx_process_t); raw_process_index = 1; diff --git a/src/kernel/context/ContextUnix.cpp b/src/kernel/context/ContextUnix.cpp index 35154dd697..692898d007 100644 --- a/src/kernel/context/ContextUnix.cpp +++ b/src/kernel/context/ContextUnix.cpp @@ -186,12 +186,15 @@ void UContextFactory::run_all() #endif } else { // Serial: - smx_process_t first_process = - xbt_dynar_get_as(simix_global->process_to_run, 0, smx_process_t); - sysv_process_index = 1; - SerialUContext* context = + if (xbt_dynar_is_empty(simix_global->process_to_run)) + return; + + smx_process_t first_process = + xbt_dynar_get_as(simix_global->process_to_run, 0, smx_process_t); + sysv_process_index = 1; + SerialUContext* context = static_cast(first_process->context); - context->resume(); + context->resume(); } } -- 2.20.1