this->throw_exception(std::make_exception_ptr(ForcefulKillException(host_->is_on() ? "exited" : "host failed")));
}
-void ActorImpl::kill(ActorImpl* actor)
+void ActorImpl::kill(ActorImpl* actor) const
{
xbt_assert(actor != simix_global->maestro_, "Killing maestro is a rather bad idea");
if (actor->finished_) {
}
}
-void ActorImpl::kill_all()
+void ActorImpl::kill_all() const
{
for (auto const& kv : simix_global->process_list)
if (kv.second != this)
});
}
-double ActorImpl::get_kill_time()
+double ActorImpl::get_kill_time() const
{
return kill_timer_ ? kill_timer_->get_date() : 0;
}
XBT_DEBUG("Hey! I'm suspended.");
xbt_assert(exception_ == nullptr, "Gasp! This exception may be lost by subsequent calls.");
- suspended_ = false;
- suspend();
- yield(); // Yield back to maestro without proceeding with my execution. I'll get resumed at some point
+
+ if (waiting_synchro_ != nullptr) // Not sure of when this will happen. Maybe when suspending early in the SR when a
+ waiting_synchro_->suspend(); // waiting_synchro was terminated
+
+ yield(); // Yield back to maestro without proceeding with my execution. I'll get rescheduled by resume()
}
if (exception_ != nullptr) {
suspended_ = true;
- /* If the suspended actor is waiting on a sync, suspend its synchronization. */
- if (waiting_synchro_ == nullptr) {
- auto exec = new activity::ExecImpl();
- exec->set_name("suspend").set_host(host_).set_flops_amount(0.0).start();
- waiting_synchro_ = activity::ExecImplPtr(exec);
-
- waiting_synchro_->simcalls_.push_back(&simcall_);
- }
- waiting_synchro_->suspend();
+ /* If the suspended actor is waiting on a sync, suspend its synchronization.
+ * Otherwise, it will suspend itself when scheduled, ie, very soon. */
+ if (waiting_synchro_ != nullptr)
+ waiting_synchro_->suspend();
}
void ActorImpl::resume()
return;
suspended_ = false;
- /* resume the synchronization that was blocking the resumed actor. */
+ /* resume the activity that was blocking the resumed actor. */
if (waiting_synchro_)
waiting_synchro_->resume();
+ else // Reschedule the actor if it was forcefully unscheduled in yield()
+ simix_global->actors_to_run.push_back(this);
XBT_OUT();
}
dest->pimpl_->add_actor(this);
}
-ActorImplPtr ActorImpl::init(const std::string& name, s4u::Host* host)
+ActorImplPtr ActorImpl::init(const std::string& name, s4u::Host* host) const
{
ActorImpl* actor = new ActorImpl(xbt::string(name), host);
actor->set_ppid(this->pid_);
}
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)
+ const std::unordered_map<std::string, std::string>* properties,
+ const ActorImpl* parent_actor)
{
XBT_DEBUG("Start actor %s@'%s'", name.c_str(), host->get_cname());