From: Frederic Suter Date: Wed, 10 Jul 2019 09:40:49 +0000 (+0200) Subject: fix https://framagit.org/simgrid/simgrid/issues/30 X-Git-Tag: v3.24~350 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ab820f42318db971aa940275587c2567033b1bfe fix https://framagit.org/simgrid/simgrid/issues/30 --- diff --git a/include/simgrid/actor.h b/include/simgrid/actor.h index f32860d129..47d6622677 100644 --- a/include/simgrid/actor.h +++ b/include/simgrid/actor.h @@ -46,6 +46,8 @@ XBT_PUBLIC sg_actor_t sg_actor_self(); XBT_PUBLIC aid_t sg_actor_self_get_pid(); XBT_PUBLIC aid_t sg_actor_self_get_ppid(); XBT_PUBLIC const char* sg_actor_self_get_name(); +XBT_PUBLIC void sg_actor_ref(sg_actor_t actor); +XBT_PUBLIC void sg_actor_unref(sg_actor_t actor); SG_END_DECL() diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index bbb438db96..a1d5cecc9c 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -240,6 +240,8 @@ XBT_PUBLIC msg_process_t MSG_process_self(); XBT_PUBLIC aid_t MSG_process_self_PID(); XBT_PUBLIC aid_t MSG_process_self_PPID(); XBT_PUBLIC const char* MSG_process_self_name(); +XBT_PUBLIC void MSG_process_ref(msg_process_t process); +XBT_PUBLIC void MSG_process_unref(msg_process_t process); /** @brief Object representing an ongoing communication between processes. * @@ -333,9 +335,6 @@ XBT_PUBLIC msg_error_t MSG_process_set_data(msg_process_t process, void* data); XBT_PUBLIC void MSG_process_on_exit(int_f_int_pvoid_t fun, void* data); -XBT_PUBLIC void MSG_process_ref(msg_process_t process); -XBT_PUBLIC void MSG_process_unref(msg_process_t process); - /************************** Task handling ************************************/ XBT_PUBLIC msg_task_t MSG_task_create(const char* name, double flops_amount, double bytes_amount, void* data); XBT_PUBLIC msg_task_t MSG_parallel_task_create(const char* name, int host_nb, const msg_host_t* host_list, diff --git a/src/msg/msg_legacy.cpp b/src/msg/msg_legacy.cpp index 31239fe48a..ab142c8610 100644 --- a/src/msg/msg_legacy.cpp +++ b/src/msg/msg_legacy.cpp @@ -172,6 +172,17 @@ msg_process_t MSG_process_self() return sg_actor_self(); } +/** @brief Take an extra reference on that process to prevent it to be garbage-collected */ +void MSG_process_ref(msg_process_t process) +{ + sg_actor_ref(process); +} +/** @brief Release a reference on that process so that it can get be garbage-collected */ +void MSG_process_unref(msg_process_t process) +{ + sg_actor_unref(process); +} + /* ************************** NetZones *************************** */ sg_netzone_t MSG_zone_get_root() { diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index cb98064731..d6db894423 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -177,14 +177,3 @@ void MSG_process_on_exit(int_f_int_pvoid_t fun, void* data) simgrid::s4u::this_actor::on_exit( [fun, data](bool failed) { fun(failed ? SMX_EXIT_FAILURE : SMX_EXIT_SUCCESS, data); }); } - -/** @brief Take an extra reference on that process to prevent it to be garbage-collected */ -XBT_PUBLIC void MSG_process_ref(msg_process_t process) -{ - intrusive_ptr_add_ref(process); -} -/** @brief Release a reference on that process so that it can get be garbage-collected */ -XBT_PUBLIC void MSG_process_unref(msg_process_t process) -{ - intrusive_ptr_release(process); -} diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 26d0591eff..aa175c6a4d 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -688,3 +688,14 @@ sg_actor_t sg_actor_self() { return simgrid::s4u::Actor::self(); } + +/** @brief Take an extra reference on that actor to prevent it to be garbage-collected */ +void sg_actor_ref(sg_actor_t actor) +{ + intrusive_ptr_add_ref(actor); +} +/** @brief Release a reference on that actor so that it can get be garbage-collected */ +void sg_actor_unref(sg_actor_t actor) +{ + intrusive_ptr_release(actor); +}