I'm not fond of the names for the new methods, but don't have a better idea.
/* Check out for errors */
if (not simcall->issuer_->get_host()->is_on()) {
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
} else {
switch (state_) {
case State::DONE:
case State::SRC_HOST_FAILURE:
if (simcall->issuer_ == src_actor_)
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
else
simcall->issuer_->exception_ =
std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
case State::DST_HOST_FAILURE:
if (simcall->issuer_ == dst_actor_)
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
else
simcall->issuer_->exception_ =
std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
case State::FAILED:
XBT_DEBUG("ExecImpl::finish(): host '%s' failed", simcall->issuer_->get_host()->get_cname());
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
if (simcall->issuer_->get_host()->is_on())
simcall->issuer_->exception_ =
std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed"));
if (simcall->issuer_->get_host()->is_on())
simcall->issuer_->simcall_answer();
else
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
}
}
/* do nothing, synchro done */
break;
case State::FAILED:
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
simcall->issuer_->exception_ =
std::make_exception_ptr(StorageFailureException(XBT_THROW_POINT, "Storage failed"));
break;
if (state_ == State::FAILED) {
XBT_DEBUG("RawImpl::finish(): host '%s' failed", simcall->issuer_->get_host()->get_cname());
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
simcall->issuer_->exception_ = std::make_exception_ptr(HostFailureException(XBT_THROW_POINT, "Host failed"));
} else if (state_ != State::SRC_TIMEOUT) {
xbt_die("Internal error in RawImpl::finish() unexpected synchro state %d", static_cast<int>(state_));
if (on_exit) {
// Execute the termination callbacks
- bool failed = context_->iwannadie;
+ bool failed = context_->wannadie();
for (auto exit_fun = on_exit->crbegin(); exit_fun != on_exit->crend(); ++exit_fun)
(*exit_fun)(failed);
on_exit.reset();
}
cleanup_from_simix();
- context_->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
+ context_->set_wannadie(false); // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
actor::simcall([this] { s4u::Actor::on_termination(*ciface()); });
- context_->iwannadie = true;
+ context_->set_wannadie();
}
void ActorImpl::exit()
{
- context_->iwannadie = true;
+ context_->set_wannadie();
suspended_ = false;
exception_ = nullptr;
/* Ok, maestro returned control to us */
XBT_DEBUG("Control returned to me: '%s'", get_cname());
- if (context_->iwannadie) {
+ if (context_->wannadie()) {
XBT_DEBUG("Actor %s@%s is dead", get_cname(), host_->get_cname());
context_->stop();
THROW_IMPOSSIBLE;
{
XBT_IN("actor = %p", this);
- if (context_->iwannadie) {
+ if (context_->wannadie()) {
XBT_VERB("Ignoring request to suspend an actor that is currently dying.");
return;
}
std::function<void()> code_;
actor::ActorImpl* actor_ = nullptr;
+ bool iwannadie_ = false;
void declare_context(std::size_t size);
public:
- bool iwannadie = false;
-
Context(std::function<void()>&& code, actor::ActorImpl* actor);
Context(const Context&) = delete;
Context& operator=(const Context&) = delete;
virtual ~Context();
+ bool wannadie() const { return iwannadie_; }
+ void set_wannadie(bool value = true) { iwannadie_ = value; }
void operator()() { code_(); }
bool has_code() const { return static_cast<bool>(code_); }
actor::ActorImpl* get_actor() { return this->actor_; }
void simgrid::kernel::actor::ActorImpl::simcall_handle(int value) {
XBT_DEBUG("Handling simcall %p: %s", &simcall, SIMIX_simcall_name(simcall.call_));
SIMCALL_SET_MC_VALUE(simcall, value);
- if (context_->iwannadie)
+ if (context_->wannadie())
return;
switch (simcall.call_) {
case SIMCALL_EXECUTION_WAIT:
' XBT_DEBUG("Handling simcall %p: %s", &simcall, SIMIX_simcall_name(simcall.call_));\n')
fd.write(' SIMCALL_SET_MC_VALUE(simcall, value);\n')
fd.write(
- ' if (context_->iwannadie)\n')
+ ' if (context_->wannadie())\n')
fd.write(' return;\n')
fd.write(' switch (simcall.call_) {\n')