X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c641d112f8a557b61ff14c261931077773f21fbd..31d00d99590955a66d0e575e9af34e48736bab79:/src/kernel/context/ContextSwapped.cpp diff --git a/src/kernel/context/ContextSwapped.cpp b/src/kernel/context/ContextSwapped.cpp index cb2f31487d..100dcba71c 100644 --- a/src/kernel/context/ContextSwapped.cpp +++ b/src/kernel/context/ContextSwapped.cpp @@ -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. */ @@ -37,24 +37,24 @@ namespace context { /* rank of the execution thread */ thread_local uintptr_t SwappedContext::worker_id_; /* thread-specific storage for the thread id */ -SwappedContextFactory::SwappedContextFactory(std::string name) - : ContextFactory(name), parallel_(SIMIX_context_is_parallel()) +SwappedContextFactory::SwappedContextFactory() : ContextFactory(), parallel_(SIMIX_context_is_parallel()) { parmap_ = nullptr; // will be created lazily with the right parameters if needed (ie, in parallel) - workers_context_.clear(); workers_context_.resize(parallel_ ? SIMIX_context_get_nthreads() : 1, nullptr); } SwappedContextFactory::~SwappedContextFactory() { delete parmap_; - parmap_ = nullptr; - workers_context_.clear(); } SwappedContext::SwappedContext(std::function code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process, 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,9 +134,15 @@ SwappedContext::~SwappedContext() xbt_free(stack_); } +void* SwappedContext::get_stack() +{ + return stack_; +} + void SwappedContext::stop() { Context::stop(); + /* We must cut the actor execution using an exception to properly free the C++ RAII variables */ throw StopRequest(); }