- SwappedContext::set_maestro(nullptr);
- SwappedContext::initialize(parallel_);
-}
-SwappedContextFactory::~SwappedContextFactory()
-{
- SwappedContext::finalize();
-}
-
-void SwappedContext::initialize(bool parallel)
-{
- parmap_ = nullptr; // will be created lazily with the right parameters if needed (ie, in parallel)
- if (parallel) {
- workers_context_.clear();
- workers_context_.resize(SIMIX_context_get_nthreads(), nullptr);
- }
-}
-
-void SwappedContext::finalize()
-{
- delete parmap_;
- parmap_ = nullptr;
- workers_context_.clear();
-}
-
-SwappedContext* SwappedContext::maestro_context_ = nullptr;
+ // Save maestro (=context created first) in preparation for run_all
+ if (not SIMIX_context_is_parallel() && factory->maestro_context_ == nullptr)
+ factory->maestro_context_ = this;