X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/91fe7904c884b2d0f5e7408d6e9d1d99886bd365..3c7c64745aa5e60415bb85af482c7b0d0fca2b2b:/src/kernel/context/ContextThread.cpp diff --git a/src/kernel/context/ContextThread.cpp b/src/kernel/context/ContextThread.cpp index eb9b4bd025..40efb6b4c1 100644 --- a/src/kernel/context/ContextThread.cpp +++ b/src/kernel/context/ContextThread.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2009-2023. 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. */ @@ -9,7 +9,6 @@ #include "src/internal_config.h" /* loads context system definitions */ #include "src/kernel/EngineImpl.hpp" #include "xbt/function_types.h" -#include "xbt/xbt_modinter.h" /* prototype of os thread module's init/exit in XBT */ #include #include @@ -18,29 +17,27 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ker_context); -namespace simgrid { -namespace kernel { -namespace context { +namespace simgrid::kernel::context { // ThreadContextFactory ThreadContextFactory::ThreadContextFactory() : ContextFactory() { - if (stack_size != 8 * 1024 * 1024) + if (Context::stack_size != 8 * 1024 * 1024) XBT_INFO("Stack size modifications are ignored by thread factory."); - if (is_parallel()) + if (Context::is_parallel()) ParallelThreadContext::initialize(); } ThreadContextFactory::~ThreadContextFactory() { - if (is_parallel()) + if (Context::is_parallel()) ParallelThreadContext::finalize(); } ThreadContext* ThreadContextFactory::create_context(std::function&& code, actor::ActorImpl* actor, bool maestro) { - if (is_parallel()) + if (Context::is_parallel()) return this->new_context(std::move(code), actor, maestro); else return this->new_context(std::move(code), actor, maestro); @@ -48,7 +45,7 @@ ThreadContext* ThreadContextFactory::create_context(std::function&& code void ThreadContextFactory::run_all(std::vector const& actors_list) { - if (is_parallel()) + if (Context::is_parallel()) ParallelThreadContext::run_all(actors_list); else @@ -86,9 +83,7 @@ void ThreadContext::wrapper(ThreadContext* context) { Context::set_current(context); -#ifndef WIN32 - install_sigsegv_stack(nullptr, true); -#endif + install_sigsegv_stack(true); // Tell the caller (normally the maestro) we are starting, and wait for its green light context->end_.release(); context->start(); @@ -107,9 +102,7 @@ void ThreadContext::wrapper(ThreadContext* context) // Signal to the caller (normally the maestro) that we have finished: context->yield(); -#ifndef WIN32 - install_sigsegv_stack(nullptr, false); -#endif + install_sigsegv_stack(false); XBT_DEBUG("Terminating"); Context::set_current(nullptr); } @@ -166,7 +159,7 @@ void ThreadContext::attach_stop() void SerialThreadContext::run_all(std::vector const& actors_list) { - for (smx_actor_t const& actor : actors_list) { + for (auto const* actor : actors_list) { XBT_DEBUG("Handling %p", actor); auto* context = static_cast(actor->context_.get()); context->release(); @@ -191,10 +184,10 @@ void ParallelThreadContext::finalize() void ParallelThreadContext::run_all(std::vector const& actors_list) { - for (smx_actor_t const& actor : actors_list) + for (auto const* actor : actors_list) static_cast(actor->context_.get())->release(); - for (smx_actor_t const& actor : actors_list) + for (auto const* actor : actors_list) static_cast(actor->context_.get())->wait(); } @@ -215,6 +208,4 @@ XBT_PRIVATE ContextFactory* thread_factory() XBT_VERB("Activating thread context factory"); return new ThreadContextFactory(); } -} // namespace context -} // namespace kernel -} // namespace simgrid +} // namespace simgrid::kernel::context