-/* Copyright (c) 2009-2021. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2022. 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 <sanitizer/tsan_interface.h>
#endif
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ker_context);
// The name of this function is currently hardcoded in MC (as string).
// Do not change it without fixing those references as well.
#endif
try {
(*context)();
- context->Context::stop();
+ context->stop();
} catch (simgrid::ForcefulKillException const&) {
XBT_DEBUG("Caught a ForcefulKillException");
} catch (simgrid::Exception const& e) {
/* thread-specific storage for the worker's context */
thread_local SwappedContext* SwappedContext::worker_context_ = nullptr;
-SwappedContext::SwappedContext(std::function<void()>&& code, smx_actor_t actor, SwappedContextFactory* factory)
- : Context(std::move(code), actor), factory_(*factory)
+SwappedContext::SwappedContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory)
+ : Context(std::move(code), actor, not code /* maestro if no code */), factory_(*factory)
{
// Save maestro (=first created context) in preparation for run_all
if (not is_parallel() && factory_.maestro_context_ == nullptr)
#endif
}
-void SwappedContext::stop()
-{
- Context::stop();
- /* We must cut the actor execution using an exception to properly free the C++ RAII variables */
- throw ForcefulKillException();
-}
-
void SwappedContext::swap_into(SwappedContext* to)
{
#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
}
/** Maestro wants to run all ready actors */
-void SwappedContextFactory::run_all()
+void SwappedContextFactory::run_all(std::vector<actor::ActorImpl*> const& actors_list)
{
const auto* engine = EngineImpl::get_instance();
/* This function is called by maestro at the beginning of a scheduling round to get all working threads executing some
if (is_parallel()) {
// We lazily create the parmap so that all options are actually processed when doing so.
if (parmap_ == nullptr)
- parmap_ = std::make_unique<simgrid::xbt::Parmap<smx_actor_t>>(get_nthreads(), get_parallel_mode());
+ parmap_ = std::make_unique<simgrid::xbt::Parmap<actor::ActorImpl*>>(get_nthreads(), get_parallel_mode());
// Usually, Parmap::apply() executes the provided function on all elements of the array.
// Here, the executed function does not return the control to the parmap before all the array is processed:
auto* context = static_cast<SwappedContext*>(actor->context_.get());
context->resume();
},
- engine->get_actors_to_run());
+ actors_list);
} else { // sequential execution
- if (not engine->has_actors_to_run())
+ if (actors_list.empty())
return;
/* maestro is already saved in the first slot of workers_context_ */
SwappedContext* next_context;
if (is_parallel()) {
// Get some more work to directly swap into the next executable actor instead of yielding back to the parmap
- boost::optional<smx_actor_t> next_work = factory_.parmap_->next();
+ boost::optional<actor::ActorImpl*> next_work = factory_.parmap_->next();
if (next_work) {
// There is a next soul to embody (ie, another executable actor)
XBT_DEBUG("Run next process");