public:
std::string name;
std::function<void()> code;
- void *data = nullptr;
- sg_host_t host = nullptr;
+ void* data = nullptr;
+ s4u::Host* host = nullptr;
double kill_time = 0.0;
std::shared_ptr<std::map<std::string, std::string>> properties;
bool auto_restart = false;
+ ProcessArg() = default;
+ explicit ProcessArg(std::string name, std::function<void()> code, void* data, s4u::Host* host, double kill_time,
+ std::shared_ptr<std::map<std::string, std::string>> properties, bool auto_restart)
+ : name(name)
+ , code(std::move(code))
+ , data(data)
+ , host(host)
+ , kill_time(kill_time)
+ , properties(properties)
+ , auto_restart(auto_restart)
+ {
+ }
};
class ActorImpl : public simgrid::surf::PropertyHolder {
actor.kill_time = process_kill_time;
actor.start_time = process_start_time;
actor.on_failure = ActorOnFailure::DIE;
- sg_platf_new_process(&actor);
+ sg_platf_new_actor(&actor);
}
namespace simgrid {
double kill_time, std::map<std::string, std::string>* properties,
int auto_restart)
{
- smx_process_arg_t arg = new simgrid::simix::ProcessArg();
- arg->name = name;
- arg->code = std::move(code);
- arg->data = data;
- arg->host = host;
- arg->kill_time = kill_time;
+ simgrid::simix::ProcessArg* arg =
+ new simgrid::simix::ProcessArg(name, code, data, host, kill_time, nullptr, auto_restart);
arg->properties.reset(properties, [](decltype(properties)) {});
- arg->auto_restart = auto_restart;
if (host->isOff() && watched_hosts.find(host->getCname()) == watched_hosts.end()) {
watched_hosts.insert(host->getCname());
}
host->extension<simgrid::simix::Host>()->auto_restart_processes.push_back(arg);
}
+
/** @brief Restart the list of processes that have been registered to the host */
void SIMIX_host_autorestart(sg_host_t host)
{
boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
SIMIX_execution_start(const char* name, double flops_amount, double priority, double bound, sg_host_t host)
{
-
/* alloc structures and initialize */
simgrid::kernel::activity::ExecImplPtr exec =
simgrid::kernel::activity::ExecImplPtr(new simgrid::kernel::activity::ExecImpl(name, host));
bypassRoute->link_list, bypassRoute->symmetrical);
}
-void sg_platf_new_process(ActorCreationArgs* actor)
+void sg_platf_new_actor(ActorCreationArgs* actor)
{
sg_host_t host = sg_host_by_name(actor->host);
if (not host) {
// The requested host does not exist. Do a nice message to the user
- std::string msg = std::string("Cannot create process '") + actor->function + "': host '" + actor->host +
+ std::string msg = std::string("Cannot create actor '") + actor->function + "': host '" + actor->host +
"' does not exist\nExisting hosts: '";
std::vector<simgrid::s4u::Host*> list;
double start_time = actor->start_time;
double kill_time = actor->kill_time;
- int auto_restart = actor->on_failure == ActorOnFailure::DIE ? 0 : 1;
+ bool auto_restart = actor->on_failure != ActorOnFailure::DIE;
- std::string process_name = actor->args[0];
+ std::string actor_name = actor->args[0];
std::function<void()> code = factory(std::move(actor->args));
std::shared_ptr<std::map<std::string, std::string>> properties(actor->properties);
- smx_process_arg_t arg = nullptr;
-
- arg = new simgrid::simix::ProcessArg();
- arg->name = process_name;
- arg->code = code;
- arg->data = nullptr;
- arg->host = host;
- arg->kill_time = kill_time;
- arg->properties = properties;
+ simgrid::simix::ProcessArg* arg =
+ new simgrid::simix::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart);
host->extension<simgrid::simix::Host>()->boot_processes.push_back(arg);
if (start_time > SIMIX_get_clock()) {
- arg = new simgrid::simix::ProcessArg();
- arg->name = process_name;
- arg->code = std::move(code);
- arg->data = nullptr;
- arg->host = host;
- arg->kill_time = kill_time;
- arg->properties = properties;
+ arg = new simgrid::simix::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart);
XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->getCname(), start_time);
SIMIX_timer_set(start_time, [arg, auto_restart]() {
XBT_PUBLIC(void) sg_platf_new_storage_type(StorageTypeCreationArgs* storage_type);
XBT_PUBLIC(void) sg_platf_new_mount(MountCreationArgs* mount);
-XBT_PUBLIC(void) sg_platf_new_process(ActorCreationArgs* actor);
+XBT_PUBLIC(void) sg_platf_new_actor(ActorCreationArgs* actor);
XBT_PRIVATE void sg_platf_trace_connect(TraceConnectCreationArgs* trace_connect);
/* Prototypes of the functions offered by flex */
break;
}
- sg_platf_new_process(&actor);
+ sg_platf_new_actor(&actor);
}
void STag_surfxml_argument(){