X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e816186fdeaf53fa5abf6886f157c499e09c4622..b37037e5e2125306aa1c5472c9171cda0791cca0:/src/kernel/context/ContextThread.cpp diff --git a/src/kernel/context/ContextThread.cpp b/src/kernel/context/ContextThread.cpp index d22c7aa318..2037673a52 100644 --- a/src/kernel/context/ContextThread.cpp +++ b/src/kernel/context/ContextThread.cpp @@ -10,7 +10,6 @@ #include "src/simix/smx_private.hpp" #include "src/xbt_modinter.h" /* prototype of os thread module's init/exit in XBT */ #include "xbt/function_types.h" -#include "xbt/xbt_os_thread.h" #include #include @@ -23,8 +22,7 @@ namespace context { // ThreadContextFactory -ThreadContextFactory::ThreadContextFactory() - : ContextFactory("ThreadContextFactory"), parallel_(SIMIX_context_is_parallel()) +ThreadContextFactory::ThreadContextFactory() : ContextFactory(), parallel_(SIMIX_context_is_parallel()) { if (parallel_) ParallelThreadContext::initialize(); @@ -37,12 +35,12 @@ ThreadContextFactory::~ThreadContextFactory() } ThreadContext* ThreadContextFactory::create_context(std::function code, void_pfn_smxprocess_t cleanup, - smx_actor_t process, bool maestro) + smx_actor_t actor, bool maestro) { if (parallel_) - return this->new_context(std::move(code), cleanup, process, maestro); + return this->new_context(std::move(code), cleanup, actor, maestro); else - return this->new_context(std::move(code), cleanup, process, maestro); + return this->new_context(std::move(code), cleanup, actor, maestro); } void ThreadContextFactory::run_all() @@ -61,11 +59,11 @@ void ThreadContextFactory::run_all() ThreadContext::ThreadContext(std::function code, void_pfn_smxprocess_t cleanup, smx_actor_t actor, bool maestro) : AttachContext(std::move(code), cleanup, actor), is_maestro_(maestro) { - /* If the user provided a function for the process then use it */ + /* If the user provided a function for the actor then use it */ if (has_code()) { - /* create and start the process */ + /* create and start the actor */ this->thread_ = new std::thread(ThreadContext::wrapper, this); - /* wait the starting of the newly created process */ + /* wait the starting of the newly created actor */ this->end_.acquire(); } @@ -77,8 +75,10 @@ ThreadContext::ThreadContext(std::function code, void_pfn_smxprocess_t c ThreadContext::~ThreadContext() { - if (this->thread_) /* If there is a thread (maestro don't have any), wait for its termination */ + if (this->thread_) { /* Maestro don't have any thread */ thread_->join(); + delete thread_; + } } void *ThreadContext::wrapper(void *param) @@ -178,9 +178,9 @@ void ThreadContext::attach_stop() void SerialThreadContext::run_all() { - for (smx_actor_t const& process : simix_global->process_to_run) { - XBT_DEBUG("Handling %p", process); - ThreadContext* context = static_cast(process->context_); + for (smx_actor_t const& actor : simix_global->process_to_run) { + XBT_DEBUG("Handling %p", actor); + ThreadContext* context = static_cast(actor->context_); context->release(); context->wait(); } @@ -203,10 +203,10 @@ void ParallelThreadContext::finalize() void ParallelThreadContext::run_all() { - for (smx_actor_t const& process : simix_global->process_to_run) - static_cast(process->context_)->release(); - for (smx_actor_t const& process : simix_global->process_to_run) - static_cast(process->context_)->wait(); + for (smx_actor_t const& actor : simix_global->process_to_run) + static_cast(actor->context_)->release(); + for (smx_actor_t const& actor : simix_global->process_to_run) + static_cast(actor->context_)->wait(); } void ParallelThreadContext::start_hook()