if (actor_list_.size() == daemons_.size())
for (auto const& dmon : daemons_) {
XBT_DEBUG("Kill %s", dmon->get_cname());
- simix_global->maestro_->kill(dmon);
+ simix_global->get_maestro()->kill(dmon);
}
}
simgrid::s4u::Engine::on_deadlock();
for (auto const& kv : actor_list_) {
XBT_DEBUG("Kill %s", kv.second->get_cname());
- simix_global->maestro_->kill(kv.second);
+ simix_global->get_maestro()->kill(kv.second);
}
}
} while (time > -1.0 || has_actors_to_run());
ActorImpl::~ActorImpl()
{
- if (simix_global != nullptr && this != simix_global->maestro_)
+ if (simix_global != nullptr && not simix_global->is_maestro(this))
s4u::Actor::on_destruction(*get_ciface());
}
XBT_DEBUG("%s@%s(%ld) should not run anymore", get_cname(), get_host()->get_cname(), get_pid());
- if (this == simix_global->maestro_) /* Do not cleanup maestro */
+ if (simix_global->is_maestro(this)) /* Do not cleanup maestro */
return;
XBT_DEBUG("Cleanup actor %s (%p), waiting synchro %p", get_cname(), this, waiting_synchro_.get());
void ActorImpl::kill(ActorImpl* actor) const
{
- xbt_assert(actor != simix_global->maestro_, "Killing maestro is a rather bad idea");
+ xbt_assert(not simix_global->is_maestro(actor), "Killing maestro is a rather bad idea");
if (actor->finished_) {
XBT_DEBUG("Ignoring request to kill actor %s@%s that is already dead", actor->get_cname(),
actor->host_->get_cname());
s4u::Actor* ActorImpl::restart()
{
- xbt_assert(this != simix_global->maestro_, "Restarting maestro is not supported");
+ xbt_assert(not simix_global->is_maestro(this), "Restarting maestro is not supported");
XBT_DEBUG("Restarting actor %s on %s", get_cname(), host_->get_cname());
void ActorImpl::simcall_answer()
{
- if (this != simix_global->maestro_) {
+ if (not simix_global->is_maestro(this)) {
XBT_DEBUG("Answer simcall %s issued by %s (%p)", SIMIX_simcall_name(simcall_), get_cname(), this);
xbt_assert(simcall_.call_ != simix::Simcall::NONE);
simcall_.call_ = simix::Simcall::NONE;
}
maestro->simcall_.issuer_ = maestro;
- simix_global->maestro_ = maestro;
+ simix_global->set_maestro(maestro);
}
} // namespace actor
void ThreadContext::attach_start()
{
// We're breaking the layers here by depending on the upper layer:
- auto* maestro = static_cast<ThreadContext*>(simix_global->maestro_->context_.get());
+ auto* maestro = static_cast<ThreadContext*>(simix_global->get_maestro()->context_.get());
maestro->begin_.release();
xbt_assert(not this->is_maestro());
this->start();
xbt_assert(not this->is_maestro());
this->yield();
- auto* maestro = static_cast<ThreadContext*>(simix_global->maestro_->context_.get());
+ auto* maestro = static_cast<ThreadContext*>(simix_global->get_maestro()->context_.get());
maestro->end_.acquire();
Context::set_current(nullptr);
{
smx_actor_t self = SIMIX_process_self();
simgrid::simix::marshal(&self->simcall_, call, t...);
- if (self != simix_global->maestro_) {
+ if (not simix_global->is_maestro(self)) {
XBT_DEBUG("Yield process '%s' on simcall %s", self->get_cname(), SIMIX_simcall_name(self->simcall_));
self->yield();
} else {
{
smx_actor_t self = SIMIX_process_self();
simgrid::simix::marshal(&self->simcall_, call, t...);
- if (self != simix_global->maestro_) {
+ if (not simix_global->is_maestro(self)) {
XBT_DEBUG("Yield process '%s' on simcall %s", self->get_cname(), SIMIX_simcall_name(self->simcall_));
self->yield();
} else {
surf_init(argc, argv); /* Initialize SURF structures */
- simix_global->maestro_ = nullptr;
SIMIX_context_mod_init();
// Either create a new context with maestro or create
#endif
/* Kill all processes (but maestro) */
- simix_global->maestro_->kill_all();
+ simix_global->get_maestro()->kill_all();
engine->run_all_actors();
engine->empty_trash();
/* Let's free maestro now */
- delete simix_global->maestro_;
- simix_global->maestro_ = nullptr;
+ simix_global->destroy_maestro();
/* Finish context module and SURF */
simix_global->destroy_context_factory();
{
if (simix_global == nullptr) // SimDag
return true;
- const simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
- return self == nullptr || self == simix_global->maestro_;
+ simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
+ return self == nullptr || simix_global->is_maestro(self);
}
class Global {
kernel::context::ContextFactory* context_factory_ = nullptr;
+ kernel::actor::ActorImpl* maestro_ = nullptr;
public:
- kernel::actor::ActorImpl* maestro_ = nullptr;
+ bool is_maestro(kernel::actor::ActorImpl* actor) const { return actor == maestro_; }
+ void set_maestro(kernel::actor::ActorImpl* actor) { maestro_ = actor; }
+ kernel::actor::ActorImpl* get_maestro() const { return maestro_; }
+ void destroy_maestro()
+ {
+ delete maestro_;
+ maestro_ = nullptr;
+ }
+
kernel::context::ContextFactory* get_context_factory() const { return context_factory_; }
void set_context_factory(kernel::context::ContextFactory* factory) { context_factory_ = factory; }
bool has_context_factory() const { return context_factory_ != nullptr; }