smx_actor_t self = SIMIX_process_self();
sg_host_t host = jhost_get_native(env, jhost);
smx_actor_t actor = simgrid::kernel::actor::simcall([name, actor_code, host, self] {
- return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(actor_code), nullptr, host, nullptr,
- self)
- .get();
+ return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(actor_code), nullptr, host, self).get();
});
sg_actor_yield();
* In the future, it might be extended in order to attach other threads created by a third party library.
*/
-ActorImplPtr ActorImpl::attach(const std::string& name, void* data, s4u::Host* host,
- const std::unordered_map<std::string, std::string>& properties)
+ActorImplPtr ActorImpl::attach(const std::string& name, void* data, s4u::Host* host)
{
// This is mostly a copy/paste from create(), it'd be nice to share some code between those two functions.
xbt_assert(simix_global != nullptr, "simix is not initialized, please call MSG_init first");
actor->context_.reset(simix_global->context_factory->attach(actor));
- /* Add properties */
- actor->set_properties(properties);
-
/* Add the actor to it's host actor list */
host->get_impl()->add_actor(actor);
context::Context::self()->get_actor()->kill(this);
// start the new actor
- ActorImplPtr actor = ActorImpl::create(arg.name, arg.code, arg.data, arg.host, arg.properties, nullptr);
+ ActorImplPtr actor = ActorImpl::create(arg.name, arg.code, arg.data, arg.host, nullptr);
+ actor->set_properties(arg.properties);
*actor->on_exit = std::move(*arg.on_exit);
actor->set_kill_time(arg.kill_time);
actor->set_auto_restart(arg.auto_restart);
}
ActorImplPtr ActorImpl::create(const std::string& name, const ActorCode& code, void* data, s4u::Host* host,
- 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());
/* actor data */
actor->set_user_data(data);
- /* Add properties */
- actor->set_properties(properties);
-
actor->start(code);
return actor;
ActorImpl* start(const ActorCode& code);
static ActorImplPtr create(const std::string& name, const ActorCode& code, void* data, s4u::Host* host,
- const std::unordered_map<std::string, std::string>& properties,
const ActorImpl* parent_actor);
- static ActorImplPtr attach(const std::string& name, void* data, s4u::Host* host,
- const std::unordered_map<std::string, std::string>& properties);
+ static ActorImplPtr attach(const std::string& name, void* data, s4u::Host* host);
static void detach();
void cleanup();
void exit();
/* list of functions executed when the process dies */
const std::shared_ptr<std::vector<std::function<void(bool)>>> on_exit;
- ProcessArg() = default;
+ ProcessArg() = delete;
explicit ProcessArg(const std::string& name, const std::function<void()>& code, void* data, s4u::Host* host,
double kill_time, const std::unordered_map<std::string, std::string>& properties,
/* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
smx_actor_t actor = nullptr;
try {
- actor = simgrid::kernel::actor::ActorImpl::attach(name, data, host, props).get();
+ actor = simgrid::kernel::actor::ActorImpl::attach(name, data, host).get();
+ actor->set_properties(props);
} catch (simgrid::HostFailureException const&) {
xbt_die("Could not attach");
}
for (auto const& arg : actors_at_boot_) {
XBT_DEBUG("Booting Actor %s(%s) right now", arg->name.c_str(), arg->host->get_cname());
simgrid::kernel::actor::ActorImplPtr actor =
- simgrid::kernel::actor::ActorImpl::create(arg->name, arg->code, nullptr, arg->host, arg->properties, nullptr);
+ simgrid::kernel::actor::ActorImpl::create(arg->name, arg->code, nullptr, arg->host, nullptr);
+ actor->set_properties(arg->properties);
if (arg->on_exit)
*actor->on_exit = *arg->on_exit;
if (arg->kill_time >= 0)
XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->get_cname(), start_time);
simgrid::simix::Timer::set(start_time, [arg, auto_restart]() {
- simgrid::kernel::actor::ActorImplPtr new_actor = simgrid::kernel::actor::ActorImpl::create(
- arg->name.c_str(), arg->code, arg->data, arg->host, arg->properties, nullptr);
+ simgrid::kernel::actor::ActorImplPtr new_actor =
+ simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), arg->code, arg->data, arg->host, nullptr);
+ new_actor->set_properties(arg->properties);
if (arg->kill_time >= 0)
new_actor->set_kill_time(arg->kill_time);
if (auto_restart)
try {
simgrid::kernel::actor::ActorImplPtr new_actor = nullptr;
- new_actor =
- simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), code, nullptr, host, arg->properties, nullptr);
+ new_actor = simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), code, nullptr, host, nullptr);
+ new_actor->set_properties(arg->properties);
/* The actor creation will fail if the host is currently dead, but that's fine */
if (arg->kill_time >= 0)
new_actor->set_kill_time(arg->kill_time);