+ delete this->context_;
+}
+
+static void dying_daemon(int /*exit_status*/, void* data)
+{
+ std::vector<ActorImpl*>* vect = &simix_global->daemons;
+
+ auto it = std::find(vect->begin(), vect->end(), static_cast<ActorImpl*>(data));
+ xbt_assert(it != vect->end(), "The dying daemon is not a daemon after all. Please report that bug.");
+
+ /* Don't move the whole content since we don't really care about the order */
+ std::swap(*it, vect->back());
+ vect->pop_back();
+}
+
+/** This process will be terminated automatically when the last non-daemon process finishes */
+void ActorImpl::daemonize()
+{
+ if (not daemon_) {
+ daemon_ = true;
+ simix_global->daemons.push_back(this);
+ SIMIX_process_on_exit(this, dying_daemon, this);
+ }
+}
+
+simgrid::s4u::Actor* ActorImpl::restart()
+{
+ XBT_DEBUG("Restarting process %s on %s", get_cname(), host_->get_cname());
+
+ // retrieve the arguments of the old process
+ simgrid::kernel::actor::ProcessArg arg = ProcessArg(host_, this);
+
+ // kill the old process
+ SIMIX_process_kill(this, (this == simix_global->maestro_process) ? this : SIMIX_process_self());
+
+ // start the new process
+ ActorImpl* actor = simix_global->create_process_function(arg.name.c_str(), std::move(arg.code), arg.data, arg.host,
+ arg.properties.get(), nullptr);
+ simcall_process_set_kill_time(actor, arg.kill_time);
+ actor->set_auto_restart(arg.auto_restart);
+
+ return actor->ciface();