#include "src/mc/mc_replay.hpp"
#include "src/mc/remote/Client.hpp"
#include "src/simix/smx_host_private.hpp"
-#include "src/simix/smx_io_private.hpp"
#include "src/simix/smx_synchro_private.hpp"
#include "src/surf/HostImpl.hpp"
#include "src/surf/cpu_interface.hpp"
return process->comms.size() > 0;
}
-/**
- * @brief Moves a process to the list of processes to destroy.
- */
-void SIMIX_process_cleanup(smx_actor_t process)
-{
- XBT_DEBUG("Cleanup process %s (%p), waiting synchro %p", process->get_cname(), process,
- process->waiting_synchro.get());
-
- simix_global->mutex.lock();
-
- simix_global->process_list.erase(process->get_pid());
- if (process->get_host() && process->host_process_list_hook.is_linked())
- simgrid::xbt::intrusive_erase(process->get_host()->pimpl_->process_list_, *process);
- if (not process->smx_destroy_list_hook.is_linked()) {
-#if SIMGRID_HAVE_MC
- xbt_dynar_push_as(simix_global->dead_actors_vector, smx_actor_t, process);
-#endif
- simix_global->actors_to_destroy.push_back(*process);
- }
- process->context_->iwannadie = false;
-
- simix_global->mutex.unlock();
-}
-
namespace simgrid {
namespace kernel {
namespace actor {
delete this->context_;
}
+void ActorImpl::cleanup()
+{
+ if (this == simix_global->maestro_process) /* Do not cleanup maestro */
+ return;
+
+ XBT_DEBUG("Cleanup actor %s (%p), waiting synchro %p", get_cname(), this, waiting_synchro.get());
+
+ simix_global->mutex.lock();
+
+ simix_global->process_list.erase(pid_);
+ if (host_ && host_process_list_hook.is_linked())
+ simgrid::xbt::intrusive_erase(host_->pimpl_->process_list_, *this);
+ if (not smx_destroy_list_hook.is_linked()) {
+#if SIMGRID_HAVE_MC
+ xbt_dynar_push_as(simix_global->dead_actors_vector, smx_actor_t, this);
+#endif
+ simix_global->actors_to_destroy.push_back(*this);
+ }
+ context_->iwannadie = false;
+
+ simix_global->mutex.unlock();
+}
+
void ActorImpl::exit()
{
context_->iwannadie = true;
if (kill_time <= SIMIX_get_clock())
return;
XBT_DEBUG("Set kill time %f for actor %s@%s", kill_time, get_cname(), host_->get_cname());
- kill_timer = SIMIX_timer_set(kill_time, [this] {
+ kill_timer = simix::Timer::set(kill_time, [this] {
this->exit();
kill_timer = nullptr;
});
double ActorImpl::get_kill_time()
{
- return SIMIX_timer_get_date(kill_timer);
+ return kill_timer ? kill_timer->get_date() : 0;
}
static void dying_daemon(int /*exit_status*/, void* data)
actor->set_ppid(parent_actor->get_pid());
XBT_VERB("Create context %s", actor->get_cname());
- actor->context_ = SIMIX_context_new(std::move(code), &SIMIX_process_cleanup, actor);
+ actor->context_ = simix_global->context_factory->create_context(std::move(code), actor);
/* Add properties */
if (properties != nullptr)
ActorImpl* maestro = new ActorImpl(xbt::string(""), /*host*/ nullptr);
if (not code) {
- maestro->context_ = SIMIX_context_new(simix::ActorCode(), nullptr, maestro);
+ maestro->context_ = simix_global->context_factory->create_context(simix::ActorCode(), maestro);
} else {
maestro->context_ = simix_global->context_factory->create_maestro(code, maestro);
}
XBT_VERB("Create context %s", actor->get_cname());
xbt_assert(simix_global != nullptr, "simix is not initialized, please call MSG_init first");
- actor->context_ = simix_global->context_factory->attach(&SIMIX_process_cleanup, actor);
+ actor->context_ = simix_global->context_factory->attach(actor);
/* Add properties */
if (properties != nullptr)
if (context == nullptr)
xbt_die("Not a suitable context");
- SIMIX_process_cleanup(context->get_actor());
+ context->get_actor()->cleanup();
context->attach_stop();
}