From: Frederic Suter Date: Wed, 30 Oct 2019 17:44:05 +0000 (+0100) Subject: add C interface to Actor::init and Actor::start X-Git-Tag: v3.25~476 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6f1f1b0cb7e3d05cdd450d76d402eb76ce3e3cd6?ds=sidebyside add C interface to Actor::init and Actor::start --- diff --git a/include/simgrid/actor.h b/include/simgrid/actor.h index 9b38ab555a..3703f10d11 100644 --- a/include/simgrid/actor.h +++ b/include/simgrid/actor.h @@ -20,6 +20,8 @@ SG_BEGIN_DECL() You should not access directly to the fields of the pointed structure, but always use the provided API to interact with actors. */ +XBT_PUBLIC sg_actor_t sg_actor_init(const char* name, sg_host_t host); +XBT_PUBLIC void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char** argv); XBT_PUBLIC aid_t sg_actor_get_PID(sg_actor_t actor); XBT_PUBLIC aid_t sg_actor_get_PPID(sg_actor_t actor); XBT_PUBLIC sg_actor_t sg_actor_by_PID(aid_t pid); diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 5ec46126a8..8779aef391 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -43,6 +43,7 @@ Actor* Actor::self() return self_context->get_actor()->ciface(); } + ActorPtr Actor::init(const std::string& name, s4u::Host* host) { kernel::actor::ActorImpl* self = SIMIX_process_self(); @@ -440,6 +441,19 @@ void migrate(Host* new_host) /* **************************** Public C interface *************************** */ +sg_actor_t sg_actor_init(const char* name, sg_host_t host) +{ + return simgrid::s4u::Actor::init(name, host).get(); +} + +void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char** argv) +{ + simgrid::simix::ActorCode function; + if (code) + function = simgrid::xbt::wrap_main(code, argc, static_cast(argv)); + actor->start(std::move(function)); +} + /** @ingroup m_actor_management * @brief Returns the process ID of @a actor. *