-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
ActorImpl::~ActorImpl()
{
- if (simix_global != nullptr && this != simix_global->maestro_) {
- if (context_.get() != nullptr) /* the actor was not start()ed yet. This happens if its host was initially off */
- context_->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
- actor::simcall([this] { s4u::Actor::on_destruction(*ciface()); });
- if (context_.get() != nullptr)
- context_->iwannadie = true;
- }
+ if (simix_global != nullptr && this != simix_global->maestro_)
+ s4u::Actor::on_destruction(*ciface());
}
/* Become an actor in the simulation
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;
}
return ActorImplPtr(actor);
}
-ActorImpl* ActorImpl::start(const simix::ActorCode& code)
+ActorImpl* ActorImpl::start(const ActorCode& code)
{
xbt_assert(code && host_ != nullptr, "Invalid parameters");
this->code_ = code;
XBT_VERB("Create context %s", get_cname());
- context_.reset(simix_global->context_factory->create_context(simix::ActorCode(code), this));
+ context_.reset(simix_global->context_factory->create_context(ActorCode(code), this));
XBT_DEBUG("Start context '%s'", get_cname());
return this;
}
-ActorImplPtr ActorImpl::create(const std::string& name, const simix::ActorCode& code, void* data, s4u::Host* host,
+ActorImplPtr ActorImpl::create(const std::string& name, const ActorCode& code, void* data, s4u::Host* host,
const std::unordered_map<std::string, std::string>* properties, ActorImpl* parent_actor)
{
XBT_DEBUG("Start actor %s@'%s'", name.c_str(), host->get_cname());
ActorImpl* maestro = new ActorImpl(xbt::string(""), /*host*/ nullptr);
if (not code) {
- maestro->context_.reset(simix_global->context_factory->create_context(simix::ActorCode(), maestro));
+ maestro->context_.reset(simix_global->context_factory->create_context(ActorCode(), maestro));
} else {
- maestro->context_.reset(simix_global->context_factory->create_maestro(simix::ActorCode(code), maestro));
+ maestro->context_.reset(simix_global->context_factory->create_maestro(ActorCode(code), maestro));
}
maestro->simcall.issuer_ = maestro;
* @param host where the new agent is executed.
* @param properties the properties of the process
*/
-smx_actor_t simcall_process_create(const std::string& name, const simgrid::simix::ActorCode& code, void* data,
+smx_actor_t simcall_process_create(const std::string& name, const simgrid::kernel::actor::ActorCode& code, void* data,
sg_host_t host, std::unordered_map<std::string, std::string>* properties)
{
smx_actor_t self = simgrid::kernel::actor::ActorImpl::self();