-/* 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. */
#include "simgrid/Exception.hpp"
#include "src/internal_config.h" /* loads context system definitions */
#include "src/kernel/EngineImpl.hpp"
+#include "src/xbt/xbt_modinter.h" /* prototype of os thread module's init/exit in XBT */
#include "xbt/function_types.h"
-#include "xbt/xbt_modinter.h" /* prototype of os thread module's init/exit in XBT */
#include <boost/core/demangle.hpp>
#include <functional>
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<void()>&& code, actor::ActorImpl* actor, bool maestro)
{
- if (is_parallel())
+ if (Context::is_parallel())
return this->new_context<ParallelThreadContext>(std::move(code), actor, maestro);
else
return this->new_context<SerialThreadContext>(std::move(code), actor, maestro);
void ThreadContextFactory::run_all(std::vector<actor::ActorImpl*> const& actors_list)
{
- if (is_parallel())
+ if (Context::is_parallel())
ParallelThreadContext::run_all(actors_list);
else
{
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();
// 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);
}