- return res;
-}
-}
-
-msg_process_t MSG_process_create_from_stdfunc(const char* name, std::function<void()> code, void* data, msg_host_t host,
- std::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);
-
- smx_actor_t process = simcall_process_create(name, std::move(code), msgExt, host, properties);
-
- if (not process) { /* Undo everything */
- delete msgExt;
- return nullptr;
- }
-
- simcall_process_on_exit(process, (int_f_pvoid_pvoid_t)TRACE_msg_process_kill, process);
- return process->ciface();
-}
-
-extern "C" {
-
-/* Become a process in the simulation
- *
- * Currently this can only be called by the main thread (once) and only work with some thread factories
- * (currently ThreadContextFactory).
- *
- * In the future, it might be extended in order to attach other threads created by a third party library.
- */
-msg_process_t MSG_process_attach(const char *name, void *data, msg_host_t host, xbt_dict_t properties)
-{
- xbt_assert(host != nullptr, "Invalid parameters: host and code params must not be nullptr");
- std::map<std::string, std::string> props;
- xbt_dict_cursor_t cursor = nullptr;
- char* key;
- char* value;
- xbt_dict_foreach (properties, cursor, key, value)
- props[key] = value;
- xbt_dict_free(&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 process = SIMIX_process_attach(name, new simgrid::msg::ActorExt(data), host->getCname(), &props, nullptr);
- if (not process)
- xbt_die("Could not attach");
- simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process);
- return process->ciface();
-}
-
-/** Detach a process attached with `MSG_process_attach()`
- *
- * This is called when the current process has finished its job.
- * Used in the main thread, it waits for the simulation to finish before returning. When it returns, the other
- * simulated processes and the maestro are destroyed.
- */
-void MSG_process_detach()
-{
- SIMIX_process_detach();
-}
-
-/** \ingroup m_process_management
- * \param process poor victim
- *
- * This function simply kills a \a process... scary isn't it ? :)
- */
-void MSG_process_kill(msg_process_t process)
-{
- process->kill();
-}
-
-/**
-* \brief Wait for the completion of a #msg_process_t.
-*
-* \param process the process to wait for
-* \param timeout wait until the process is over, or the timeout occurs
-*/
-msg_error_t MSG_process_join(msg_process_t process, double timeout){
- process->join(timeout);
- return MSG_OK;
-}
-
-/** Yield the current actor; let the other actors execute first */
-void MSG_process_yield()
-{
- simgrid::simix::kernelImmediate([] { /* do nothing*/ });
-}
-
-/** \ingroup m_process_management
- * \brief Returns the user data of a process.
- *
- * This function checks whether \a process is a valid pointer and returns the user data associated to this process.
- */
-void* MSG_process_get_data(msg_process_t process)
-{
- xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
-
- /* get from SIMIX the MSG process data, and then the user data */
- simgrid::msg::ActorExt* msgExt = (simgrid::msg::ActorExt*)process->getImpl()->userdata;
- if (msgExt)
- return msgExt->data;
- else
- return nullptr;
-}
-
-/** \ingroup m_process_management
- * \brief Sets the user data of a process.
- *
- * This function checks whether \a process is a valid pointer and sets the user data associated to this process.
- */
-msg_error_t MSG_process_set_data(msg_process_t process, void *data)
-{
- xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");