SG_END_DECL()
#ifdef __cplusplus
-XBT_PUBLIC msg_process_t MSG_process_create_from_stdfunc(const char* name, std::function<void()> code, void* data,
+XBT_PUBLIC msg_process_t MSG_process_create_from_stdfunc(std::string name, std::function<void()> code, void* data,
msg_host_t host,
std::unordered_map<std::string, std::string>* properties);
#endif
*
* If the actor is restarted, the actor has a fresh copy of the function.
*/
- static ActorPtr create(const char* name, s4u::Host* host, std::function<void()> code);
+ static ActorPtr create(std::string name, s4u::Host* host, std::function<void()> code);
- static ActorPtr create(const char* name, s4u::Host* host, std::function<void(std::vector<std::string>*)> code,
+ static ActorPtr create(std::string name, s4u::Host* host, std::function<void(std::vector<std::string>*)> code,
std::vector<std::string>* args)
{
return create(name, host, [code](std::vector<std::string>* args) { code(args); }, args);
template <class F, class... Args,
// This constructor is enabled only if the call code(args...) is valid:
typename = typename std::result_of<F(Args...)>::type>
- static ActorPtr create(const char* name, s4u::Host* host, F code, Args... args)
+ static ActorPtr create(std::string name, s4u::Host* host, F code, Args... args)
{
return create(name, host, wrap_task(std::move(code), std::move(args)...));
}
// Create actor from function name:
- static ActorPtr create(const char* name, s4u::Host* host, const char* function, std::vector<std::string> args);
+ static ActorPtr create(std::string name, s4u::Host* host, std::string function, std::vector<std::string> args);
// ***** Methods *****
/** This actor will be automatically terminated when the last non-daemon actor finishes **/
/** Retrieve the property value (or nullptr if not set) */
std::unordered_map<std::string, std::string>*
get_properties(); // FIXME: do not export the map, but only the keys or something
- const char* get_property(const char* key);
- void set_property(const char* key, const char* value);
+ const char* get_property(std::string key);
+ void set_property(std::string key, std::string value);
XBT_ATTRIB_DEPRECATED_v323("Please use Actor::create()") static ActorPtr createActor(
const char* name, s4u::Host* host, std::function<void()> code)
SG_BEGIN_DECL()
/* Constructor and Destructor */
#ifdef __cplusplus
-XBT_PUBLIC smx_actor_t simcall_process_create(const char* name, xbt_main_func_t code, void* data, sg_host_t host,
+XBT_PUBLIC smx_actor_t simcall_process_create(std::string name, xbt_main_func_t code, void* data, sg_host_t host,
int argc, char** argv,
std::unordered_map<std::string, std::string>* properties);
#endif
* std::map<std::string, std::string>* props: properties
*/
typedef smx_actor_t (*smx_creation_func_t)(
- /* name */ const char*, simgrid::simix::ActorCode code,
+ /* name */ std::string, simgrid::simix::ActorCode code,
/* userdata */ void*,
/* hostname */ sg_host_t,
/* props */ std::unordered_map<std::string, std::string>*,
XBT_PUBLIC void SIMIX_function_register_process_create(smx_creation_func_t function);
-XBT_PUBLIC smx_actor_t simcall_process_create(const char* name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
- std::unordered_map<std::string, std::string>* properties);
+XBT_PUBLIC smx_actor_t simcall_process_create(std::string name, simgrid::simix::ActorCode code, void* data,
+ sg_host_t host, std::unordered_map<std::string, std::string>* properties);
XBT_PUBLIC smx_timer_t SIMIX_timer_set(double date, simgrid::xbt::Task<void()> callback);
XBT_PRIVATE void SIMIX_post_create_environment();
-XBT_PRIVATE simgrid::simix::ActorCodeFactory& SIMIX_get_actor_code_factory(const char *name);
+XBT_PRIVATE simgrid::simix::ActorCodeFactory& SIMIX_get_actor_code_factory(std::string name);
#endif
/*************************************************************/
XBT_PRIVATE void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_proc);
-XBT_PRIVATE smx_actor_t MSG_process_create_from_SIMIX(const char* name, simgrid::simix::ActorCode code, void* data,
+XBT_PRIVATE smx_actor_t MSG_process_create_from_SIMIX(std::string name, simgrid::simix::ActorCode code, void* data,
sg_host_t host,
std::unordered_map<std::string, std::string>* properties,
smx_actor_t parent_process);
}
/* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
-smx_actor_t MSG_process_create_from_SIMIX(const char* name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
+smx_actor_t MSG_process_create_from_SIMIX(std::string name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
std::unordered_map<std::string, std::string>* properties,
smx_actor_t /*parent_process*/)
{
*/
msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *data, msg_host_t host)
{
- return MSG_process_create_with_environment(name, code, data, host, 0, nullptr, nullptr);
+ return MSG_process_create_with_environment(name == nullptr ? "" : name, code, data, host, 0, nullptr, nullptr);
}
/** \ingroup m_process_management
return res;
}
-msg_process_t MSG_process_create_from_stdfunc(const char* name, simgrid::simix::ActorCode code, void* data, msg_host_t host,
- std::unordered_map<std::string, std::string>* properties)
+msg_process_t MSG_process_create_from_stdfunc(std::string name, simgrid::simix::ActorCode code, void* data,
+ msg_host_t host, std::unordered_map<std::string, std::string>* properties)
{
xbt_assert(code != nullptr && host != nullptr, "Invalid parameters: host and code params must not be nullptr");
simgrid::msg::ActorExt* msgExt = new simgrid::msg::ActorExt(data);
return self_context->process()->iface();
}
-ActorPtr Actor::create(const char* name, s4u::Host* host, std::function<void()> code)
+ActorPtr Actor::create(std::string name, s4u::Host* host, std::function<void()> code)
{
simgrid::kernel::actor::ActorImpl* actor = simcall_process_create(name, std::move(code), nullptr, host, nullptr);
return actor->iface();
}
-ActorPtr Actor::create(const char* name, s4u::Host* host, const char* function, std::vector<std::string> args)
+ActorPtr Actor::create(std::string name, s4u::Host* host, std::string function, std::vector<std::string> args)
{
simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
simgrid::simix::ActorCode code = factory(std::move(args));
}
/** Retrieve the property value (or nullptr if not set) */
-const char* Actor::get_property(const char* key)
+const char* Actor::get_property(std::string key)
{
return simgrid::simix::simcall([this, key] { return pimpl_->get_property(key); });
}
-void Actor::set_property(const char* key, const char* value)
+void Actor::set_property(std::string key, std::string value)
{
simgrid::simix::simcall([this, key, value] { pimpl_->set_property(key, value); });
}
*
* \return the process created
*/
-smx_actor_t SIMIX_process_create(const char* name, simgrid::simix::ActorCode code, void* data, simgrid::s4u::Host* host,
+smx_actor_t SIMIX_process_create(std::string name, simgrid::simix::ActorCode code, void* data, simgrid::s4u::Host* host,
std::unordered_map<std::string, std::string>* properties, smx_actor_t parent_process)
{
- XBT_DEBUG("Start process %s on host '%s'", name, host->get_cname());
+ XBT_DEBUG("Start process %s on host '%s'", name.c_str(), host->get_cname());
if (host->is_off()) {
- XBT_WARN("Cannot launch process '%s' on failed host '%s'", name, host->get_cname());
+ XBT_WARN("Cannot launch process '%s' on failed host '%s'", name.c_str(), host->get_cname());
return nullptr;
}
* \param argv second argument passed to \a code
* \param properties the properties of the process
*/
-smx_actor_t simcall_process_create(const char* name, xbt_main_func_t code, void* data, sg_host_t host, int argc,
+smx_actor_t simcall_process_create(std::string name, xbt_main_func_t code, void* data, sg_host_t host, int argc,
char** argv, std::unordered_map<std::string, std::string>* properties)
{
- if (name == nullptr)
- name = "";
auto wrapped_code = simgrid::xbt::wrap_main(code, argc, argv);
for (int i = 0; i != argc; ++i)
xbt_free(argv[i]);
return res;
}
-smx_actor_t simcall_process_create(const char* name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
+smx_actor_t simcall_process_create(std::string name, simgrid::simix::ActorCode code, void* data, sg_host_t host,
std::unordered_map<std::string, std::string>* properties)
{
- if (name == nullptr)
- name = "";
smx_actor_t self = SIMIX_process_self();
return simgrid::simix::simcall([name, code, data, host, properties, self] {
return SIMIX_process_create(name, std::move(code), data, host, properties, self);
typedef simgrid::kernel::actor::ActorImpl* smx_actor_t;
-XBT_PRIVATE smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, void* data, sg_host_t host,
+XBT_PRIVATE smx_actor_t SIMIX_process_create(std::string name, std::function<void()> code, void* data, sg_host_t host,
std::unordered_map<std::string, std::string>* properties,
smx_actor_t parent_process);
* \param name the reference name of the function.
* \return The #smx_actor_t or nullptr.
*/
-simgrid::simix::ActorCodeFactory& SIMIX_get_actor_code_factory(const char *name)
+simgrid::simix::ActorCodeFactory& SIMIX_get_actor_code_factory(std::string name)
{
xbt_assert(simix_global,
"SIMIX_global_init has to be called before SIMIX_get_actor_code_factory.");