]> AND Public Git Repository - simgrid.git/blobdiff - src/kernel/context/ContextSwapped.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
s/process/actor/ A lot remains TBD about it
[simgrid.git] / src / kernel / context / ContextSwapped.cpp
index 87da1fcf615d18663ff9747c33379dc02b490bb5..1d18cc5916ff3144c3b89fb55e88d97a55abf682 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2018. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -55,6 +55,10 @@ SwappedContext::SwappedContext(std::function<void()> code, void_pfn_smxprocess_t
                                SwappedContextFactory* factory)
     : Context(std::move(code), cleanup_func, process), factory_(factory)
 {
+  // Save maestro (=context created first) in preparation for run_all
+  if (factory_->workers_context_[0] == nullptr)
+    factory_->workers_context_[0] = this;
+
   if (has_code()) {
     if (smx_context_guard_size > 0 && not MC_is_active()) {
 
@@ -134,10 +138,9 @@ SwappedContext::~SwappedContext()
   xbt_free(stack_);
 }
 
-void SwappedContext::set_maestro(SwappedContext* ctx)
+void* SwappedContext::get_stack()
 {
-  if (factory_->threads_working_ == 0) // Don't save the soul of minions, only the one of maestro
-    factory_->workers_context_[0] = ctx;
+  return stack_;
 }
 
 void SwappedContext::stop()