SURF_LINK_FATPIPE = 0
} e_surf_link_sharing_policy_t;
-typedef enum { // FIXME: move this to s4u::Actor; make it an enum class
- SURF_ACTOR_ON_FAILURE_DIE = 1,
- SURF_ACTOR_ON_FAILURE_RESTART = 0
-} e_surf_process_on_failure_t;
-
/** @ingroup m_datatypes_management_details
* @brief Type for any simgrid size
*/
void SIMIX_process_set_function(const char* process_host, const char* process_function, xbt_dynar_t arguments,
double process_start_time, double process_kill_time)
{
- s_sg_platf_process_cbarg_t process;
+ ActorCreationArgs actor;
sg_host_t host = sg_host_by_name(process_host);
if (not host)
THROWF(arg_error, 0, "Host '%s' unknown", process_host);
- process.host = process_host;
- process.args.push_back(process_function);
+ actor.host = process_host;
+ actor.args.push_back(process_function);
/* add arguments */
unsigned int i;
char *arg;
xbt_dynar_foreach(arguments, i, arg) {
- process.args.push_back(arg);
+ actor.args.push_back(arg);
}
// Check we know how to handle this function name:
simgrid::simix::ActorCodeFactory& parse_code = SIMIX_get_actor_code_factory(process_function);
xbt_assert(parse_code, "Function '%s' unknown", process_function);
- process.function = process_function;
- process.host = process_host;
- process.kill_time = process_kill_time;
- process.start_time = process_start_time;
- process.on_failure = SURF_ACTOR_ON_FAILURE_DIE;
- sg_platf_new_process(&process);
+ actor.function = process_function;
+ actor.host = process_host;
+ actor.kill_time = process_kill_time;
+ actor.start_time = process_start_time;
+ actor.on_failure = ActorOnFailure::DIE;
+ sg_platf_new_process(&actor);
}
namespace simgrid {
bypassRoute->link_list, bypassRoute->symmetrical);
}
-void sg_platf_new_process(sg_platf_process_cbarg_t process)
+void sg_platf_new_process(ActorCreationArgs* actor)
{
- sg_host_t host = sg_host_by_name(process->host);
+ 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 '") + process->function + "': host '" + process->host +
+ std::string msg = std::string("Cannot create process '") + actor->function + "': host '" + actor->host +
"' does not exist\nExisting hosts: '";
std::vector<simgrid::s4u::Host*> list;
}
xbt_die("%s", msg.c_str());
}
- simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(process->function);
- xbt_assert(factory, "Function '%s' unknown", process->function);
+ simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(actor->function);
+ xbt_assert(factory, "Function '%s' unknown", actor->function);
- double start_time = process->start_time;
- double kill_time = process->kill_time;
- int auto_restart = process->on_failure == SURF_ACTOR_ON_FAILURE_DIE ? 0 : 1;
+ double start_time = actor->start_time;
+ double kill_time = actor->kill_time;
+ int auto_restart = actor->on_failure == ActorOnFailure::DIE ? 0 : 1;
- std::string process_name = process->args[0];
- std::function<void()> code = factory(std::move(process->args));
- std::shared_ptr<std::map<std::string, std::string>> properties(process->properties);
+ std::string process_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;
std::string element;
};
-struct s_sg_platf_process_cbarg_t {
+enum class ActorOnFailure { DIE, RESTART };
+
+class ActorCreationArgs {
+public:
std::vector<std::string> args;
std::map<std::string, std::string>* properties = nullptr;
const char* host = nullptr;
const char* function = nullptr;
double start_time = 0.0;
double kill_time = 0.0;
- e_surf_process_on_failure_t on_failure = {};
+ ActorOnFailure on_failure;
};
-typedef s_sg_platf_process_cbarg_t* sg_platf_process_cbarg_t;
class ZoneCreationArgs {
public:
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(sg_platf_process_cbarg_t process);
+XBT_PUBLIC(void) sg_platf_new_process(ActorCreationArgs* actor);
XBT_PRIVATE void sg_platf_trace_connect(TraceConnectCreationArgs* trace_connect);
/* Prototypes of the functions offered by flex */
void ETag_surfxml_actor()
{
- s_sg_platf_process_cbarg_t actor;
+ ActorCreationArgs actor;
actor.properties = current_property_set;
current_property_set = nullptr;
switch (A_surfxml_actor_on___failure) {
case AU_surfxml_actor_on___failure:
case A_surfxml_actor_on___failure_DIE:
- actor.on_failure = SURF_ACTOR_ON_FAILURE_DIE;
+ actor.on_failure = ActorOnFailure::DIE;
break;
case A_surfxml_actor_on___failure_RESTART:
- actor.on_failure = SURF_ACTOR_ON_FAILURE_RESTART;
+ actor.on_failure = ActorOnFailure::RESTART;
break;
default:
surf_parse_error("Invalid on failure behavior");