From 8d35ce927dd5951b952d5baa2c898db31b8fcb4c Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 15 Jan 2020 21:22:22 +0100 Subject: [PATCH 1/1] Field 'SwappedContext::factory_' becomes a reference. --- src/kernel/context/ContextSwapped.cpp | 14 +++++++------- src/kernel/context/ContextSwapped.hpp | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/kernel/context/ContextSwapped.cpp b/src/kernel/context/ContextSwapped.cpp index 292cb593d2..c86e48c554 100644 --- a/src/kernel/context/ContextSwapped.cpp +++ b/src/kernel/context/ContextSwapped.cpp @@ -39,11 +39,11 @@ namespace context { thread_local SwappedContext* SwappedContext::worker_context_ = nullptr; SwappedContext::SwappedContext(std::function&& code, smx_actor_t actor, SwappedContextFactory* factory) - : Context(std::move(code), actor), factory_(factory) + : Context(std::move(code), actor), factory_(*factory) { // Save maestro (=context created first) in preparation for run_all - if (not SIMIX_context_is_parallel() && factory->maestro_context_ == nullptr) - factory->maestro_context_ = this; + if (not SIMIX_context_is_parallel() && factory_.maestro_context_ == nullptr) + factory_.maestro_context_ = this; if (has_code()) { xbt_assert((smx_context_stack_size & 0xf) == 0, "smx_context_stack_size should be multiple of 16"); @@ -212,7 +212,7 @@ void SwappedContext::suspend() SwappedContext* next_context; if (SIMIX_context_is_parallel()) { // Get some more work to directly swap into the next executable actor instead of yielding back to the parmap - boost::optional next_work = factory_->parmap_->next(); + boost::optional next_work = factory_.parmap_->next(); if (next_work) { // There is a next soul to embody (ie, another executable actor) XBT_DEBUG("Run next process"); @@ -226,8 +226,8 @@ void SwappedContext::suspend() } } else { // sequential execution /* determine the next context */ - unsigned long int i = factory_->process_index_; - factory_->process_index_++; + unsigned long int i = factory_.process_index_; + factory_.process_index_++; if (i < simix_global->actors_to_run.size()) { /* Actually swap into the next actor directly without transiting to maestro */ @@ -236,7 +236,7 @@ void SwappedContext::suspend() } else { /* all processes were run, actually return to maestro */ XBT_DEBUG("No more actors to run"); - next_context = factory_->maestro_context_; + next_context = factory_.maestro_context_; } } Context::set_current(next_context); diff --git a/src/kernel/context/ContextSwapped.hpp b/src/kernel/context/ContextSwapped.hpp index 4c03501267..00d2dba4ff 100644 --- a/src/kernel/context/ContextSwapped.hpp +++ b/src/kernel/context/ContextSwapped.hpp @@ -57,8 +57,8 @@ public: #endif private: - unsigned char* stack_ = nullptr; /* the thread stack */ - SwappedContextFactory* const factory_; // for sequential and parallel run_all() + unsigned char* stack_ = nullptr; // the thread stack + SwappedContextFactory& factory_; // for sequential and parallel run_all() #if HAVE_VALGRIND_H unsigned int valgrind_stack_id_; -- 2.20.1