Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Field 'SwappedContext::factory_' becomes a reference.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 15 Jan 2020 20:22:22 +0000 (21:22 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 16 Jan 2020 08:48:37 +0000 (09:48 +0100)
src/kernel/context/ContextSwapped.cpp
src/kernel/context/ContextSwapped.hpp

index 292cb59..c86e48c 100644 (file)
@@ -39,11 +39,11 @@ namespace context {
 thread_local SwappedContext* SwappedContext::worker_context_ = nullptr;
 
 SwappedContext::SwappedContext(std::function<void()>&& 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<smx_actor_t> next_work = factory_->parmap_->next();
+    boost::optional<smx_actor_t> 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);
index 4c03501..00d2dba 100644 (file)
@@ -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_;