#include "simgrid/Exception.hpp"
#include "simgrid/s4u/Host.hpp"
-#include "src/kernel/context/Context.hpp"
#include "jmsg.hpp"
#include "jmsg_host.h"
#include "jxbt_utilities.hpp"
#include "simgrid/Exception.hpp"
#include "simgrid/plugins/live_migration.h"
-#include "src/kernel/context/Context.hpp"
#include "src/kernel/resource/VirtualMachineImpl.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
#include "simgrid/kernel/ProfileBuilder.hpp"
#include "simgrid/kernel/routing/NetPoint.hpp"
-#include "src/kernel/context/Context.hpp"
#include <simgrid/Exception.hpp>
#include <simgrid/s4u/Actor.hpp>
#include <simgrid/s4u/Comm.hpp>
instance_->get_context_factory()->run_all();
for (auto const& actor : actors_to_run_)
- if (actor->context_->to_be_freed())
+ if (actor->to_be_freed())
actor->cleanup_from_kernel();
actors_to_run_.swap(actors_that_ran_);
#include "src/kernel/activity/CommImpl.hpp"
#include "src/kernel/activity/MailboxImpl.hpp"
#include "src/kernel/actor/SimcallObserver.hpp"
-#include "src/kernel/context/Context.hpp"
#include "src/kernel/resource/CpuImpl.hpp"
#include "src/kernel/resource/LinkImpl.hpp"
#include "src/kernel/resource/StandardLinkImpl.hpp"
case State::SRC_HOST_FAILURE:
if (issuer == src_actor_)
- issuer->context_->set_wannadie();
+ issuer->set_wannadie();
else {
set_state(State::FAILED);
issuer->exception_ = std::make_exception_ptr(NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
case State::DST_HOST_FAILURE:
if (issuer == dst_actor_)
- issuer->context_->set_wannadie();
+ issuer->set_wannadie();
else {
set_state(State::FAILED);
issuer->exception_ = std::make_exception_ptr(NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
/* Check out for errors */
if (not simcall->issuer_->get_host()->is_on()) {
- simcall->issuer_->context_->set_wannadie();
+ simcall->issuer_->set_wannadie();
} else {
// Do not answer to dying actors
- if (not simcall->issuer_->context_->wannadie()) {
+ if (not simcall->issuer_->wannadie()) {
set_exception(simcall->issuer_);
simcall->issuer_->simcall_answer();
}
if (issuer->get_host()->is_on())
issuer->exception_ = std::make_exception_ptr(HostFailureException(XBT_THROW_POINT, "Host failed"));
else /* else, the actor will be killed with no possibility to survive */
- issuer->context_->set_wannadie();
+ issuer->set_wannadie();
break;
case State::CANCELED:
if (simcall->issuer_->get_host()->is_on())
simcall->issuer_->simcall_answer();
else
- simcall->issuer_->context_->set_wannadie();
+ simcall->issuer_->set_wannadie();
}
}
#include "src/kernel/activity/IoImpl.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
#include "src/kernel/actor/SimcallObserver.hpp"
-#include "src/kernel/context/Context.hpp"
#include "src/kernel/resource/CpuImpl.hpp"
#include "src/kernel/resource/DiskImpl.hpp"
#include "src/mc/mc_replay.hpp"
{
switch (get_state()) {
case State::FAILED:
- issuer->context_->set_wannadie();
+ issuer->set_wannadie();
static_cast<s4u::Io*>(get_iface())->complete(s4u::Activity::State::FAILED);
issuer->exception_ = std::make_exception_ptr(StorageFailureException(XBT_THROW_POINT, "Storage failed"));
break;
#include "src/kernel/activity/Synchro.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
-#include "src/kernel/context/Context.hpp"
#include "src/kernel/resource/CpuImpl.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_synchro, kernel,
void SynchroImpl::set_exception(actor::ActorImpl* issuer)
{
if (get_state() == State::FAILED) {
- issuer->context_->set_wannadie();
+ issuer->set_wannadie();
issuer->exception_ = std::make_exception_ptr(HostFailureException(XBT_THROW_POINT, "Host failed"));
} else {
xbt_assert(get_state() == State::SRC_TIMEOUT, "Internal error in SynchroImpl::finish() unexpected synchro state %s",
void ActorImpl::cleanup_from_self()
{
xbt_assert(not ActorImpl::is_maestro(), "Cleanup_from_self called from maestro on '%s'", get_cname());
- context_->set_to_be_freed();
+ set_to_be_freed();
if (on_exit) {
// Execute the termination callbacks
- bool failed = context_->wannadie();
+ bool failed = wannadie();
for (auto exit_fun = on_exit->crbegin(); exit_fun != on_exit->crend(); ++exit_fun)
(*exit_fun)(failed);
on_exit.reset();
simcall_.timeout_cb_ = nullptr;
}
- context_->set_wannadie(false); // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
+ set_wannadie(false); // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
actor::simcall_answered([this] { s4u::Actor::on_termination(*get_ciface()); });
- context_->set_wannadie();
+ set_wannadie();
}
void ActorImpl::exit()
{
- context_->set_wannadie();
+ set_wannadie();
suspended_ = false;
exception_ = nullptr;
void ActorImpl::kill(ActorImpl* actor) const
{
xbt_assert(not actor->is_maestro(), "Killing maestro is a rather bad idea.");
- if (actor->context_->wannadie()) {
+ if (actor->wannadie()) {
XBT_DEBUG("Ignoring request to kill actor %s@%s that is already dead", actor->get_cname(),
actor->host_->get_cname());
return;
/* Ok, maestro returned control to us */
XBT_DEBUG("Control returned to me: '%s'", get_cname());
- if (context_->wannadie()) {
+ if (wannadie()) {
XBT_DEBUG("Actor %s@%s is dead", get_cname(), host_->get_cname());
context_->stop();
THROW_IMPOSSIBLE;
}
}
#if HAVE_SMPI
- if (not context_->wannadie())
+ if (not wannadie())
smpi_switch_data_segment(get_iface());
#endif
}
{
XBT_IN("actor = %p", this);
- if (context_->wannadie()) {
+ if (wannadie()) {
XBT_VERB("Ignoring request to resume an actor that is currently dying.");
return;
}
activity::ActivityImplPtr ActorImpl::join(const ActorImpl* actor, double timeout)
{
activity::ActivityImplPtr sleep = this->sleep(timeout);
- if (actor->context_->wannadie() || actor->context_->to_be_freed()) {
+ if (actor->wannadie() || actor->to_be_freed()) {
if (sleep->surf_action_)
sleep->surf_action_->finish(resource::Action::State::FINISHED);
} else {
actor->daemonize();
return actor;
}
+void ActorImpl::set_wannadie(bool value)
+{
+ XBT_DEBUG("Actor %s gonna die.", get_cname());
+ iwannadie_ = value;
+}
void create_maestro(const std::function<void()>& code)
{
aid_t ppid_ = -1;
bool daemon_ = false; /* Daemon actors are automatically killed when the last non-daemon leaves */
unsigned stacksize_; // set to default value in constructor
+ bool iwannadie_ = false; // True if we need to do some cleanups in actor mode.
+ bool to_be_freed_ = false; // True if cleanups in actor mode done, but cleanups in kernel mode pending
std::vector<activity::MailboxImpl*> mailboxes_;
friend activity::MailboxImpl;
const xbt::string& get_name() const { return name_; }
const char* get_cname() const { return name_.c_str(); }
+ // Life-cycle
+ bool wannadie() const { return iwannadie_; }
+ void set_wannadie(bool value = true);
+ bool to_be_freed() const { return to_be_freed_; }
+ void set_to_be_freed() { to_be_freed_ = true; }
+
// Accessors to private fields
s4u::Host* get_host() const { return host_; }
void set_host(s4u::Host* dest);
XBT_DEBUG("Handling simcall %p: %s", &simcall_, simcall_.get_cname());
if (simcall_.observer_ != nullptr)
simcall_.observer_->prepare(times_considered);
- if (context_->wannadie())
+ if (wannadie())
return;
xbt_assert(simcall_.call_ != Simcall::Type::NONE, "Asked to do the noop syscall on %s@%s", get_cname(),
this->actor_->cleanup_from_self();
throw ForcefulKillException(); // clean RAII variables with the dedicated exception
}
-
-void Context::set_wannadie(bool value)
-{
- XBT_DEBUG("Actor %s gonna die.", actor_->get_cname());
- iwannadie_ = value;
-}
AttachContext::~AttachContext() = default;
} // namespace context
std::function<void()> code_;
actor::ActorImpl* actor_ = nullptr;
- bool iwannadie_ = false; // True if we need to do some cleanups in actor mode.
- bool to_be_freed_ = false; // True if cleanups in actor mode done, but cleanups in kernel mode pending
bool is_maestro_;
void declare_context(std::size_t size);
Context& operator=(const Context&) = delete;
virtual ~Context();
- bool wannadie() const { return iwannadie_; }
- void set_wannadie(bool value = true);
- bool to_be_freed() const { return to_be_freed_; }
- void set_to_be_freed() { to_be_freed_ = true; }
bool is_maestro() const { return is_maestro_; }
void operator()() const { code_(); }
bool has_code() const { return static_cast<bool>(code_); }
#include <xbt/parmap.hpp>
#include "src/internal_config.h"
-#include "src/kernel/context/Context.hpp"
#include "src/kernel/context/ContextSwapped.hpp"
namespace simgrid {
#include "src/mc/mc_record.hpp"
#include "src/kernel/activity/CommImpl.hpp"
-#include "src/kernel/context/Context.hpp"
#include "src/mc/mc_base.hpp"
#include "src/mc/mc_replay.hpp"
#include "src/mc/transition/Transition.hpp"
#include "src/include/mc/mc.h"
#include "src/kernel/EngineImpl.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
-#include "src/kernel/context/Context.hpp"
#include "src/mc/mc_replay.hpp"
#include "src/surf/HostImpl.hpp"
kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
const kernel::actor::ActorImpl* target = pimpl_;
kernel::actor::simcall_blocking([issuer, target, timeout] {
- if (target->context_->wannadie()) {
+ if (target->wannadie()) {
// The joined actor is already finished, just wake up the issuer right away
issuer->simcall_answer();
} else {
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/Exception.hpp"
-#include "src/kernel/context/Context.hpp"
#include <xbt/config.hpp>
#include <xbt/log.hpp>