From d99d3238efb76357fcc6437c15fb900c3c02ebd4 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 21 Apr 2016 20:21:57 +0200 Subject: [PATCH] cleanups in mailbox module init/fini --- src/simix/smx_global.cpp | 4 +--- src/simix/smx_network.cpp | 12 ++++-------- src/simix/smx_network_private.h | 3 +-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index d039e8cd1e..6e71f22486 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -230,8 +230,6 @@ void SIMIX_global_init(int *argc, char **argv) __xbt_running_ctx_fetch = SIMIX_process_get_running_context; __xbt_ex_terminate = SIMIX_process_exception_terminate; - SIMIX_network_init(); - /* Prepare to display some more info when dying on Ctrl-C pressing */ signal(SIGINT, inthandler); @@ -298,7 +296,7 @@ void SIMIX_clean(void) SIMIX_process_killall(simix_global->maestro_process, 1); /* Exit the SIMIX network module */ - SIMIX_network_exit(); + SIMIX_mailbox_exit(); xbt_heap_free(simix_timers); simix_timers = NULL; diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index 977fe430bd..b1cf01d19a 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -10,10 +10,12 @@ #include "mc/mc.h" #include "src/mc/mc_replay.h" #include "xbt/dict.h" +#include "simgrid/s4u/mailbox.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_network, simix, "SIMIX network-related synchronization"); -static xbt_dict_t mailboxes = NULL; +static void SIMIX_mbox_free(void *data); +static xbt_dict_t mailboxes = xbt_dict_new_homogeneous(SIMIX_mbox_free); static void SIMIX_waitany_remove_simcall_from_actions(smx_simcall_t simcall); static void SIMIX_comm_copy_data(smx_synchro_t comm); @@ -25,15 +27,9 @@ static smx_synchro_t SIMIX_fifo_probe_comm(xbt_fifo_t fifo, e_smx_comm_type_t ty static smx_synchro_t SIMIX_fifo_get_comm(xbt_fifo_t fifo, e_smx_comm_type_t type, int (*match_fun)(void *, void *,smx_synchro_t), void *user_data, smx_synchro_t my_synchro); -static void SIMIX_mbox_free(void *data); static void SIMIX_comm_start(smx_synchro_t synchro); -void SIMIX_network_init(void) -{ - mailboxes = xbt_dict_new_homogeneous(SIMIX_mbox_free); -} - -void SIMIX_network_exit(void) +void SIMIX_mailbox_exit(void) { xbt_dict_free(&mailboxes); } diff --git a/src/simix/smx_network_private.h b/src/simix/smx_network_private.h index f2a93b8653..0484c4b8f4 100644 --- a/src/simix/smx_network_private.h +++ b/src/simix/smx_network_private.h @@ -21,8 +21,7 @@ typedef struct s_smx_mailbox { xbt_fifo_t done_comm_fifo;//messages already received in the permanent receive mode } s_smx_mailbox_t; -XBT_PRIVATE void SIMIX_network_init(void); -XBT_PRIVATE void SIMIX_network_exit(void); +XBT_PRIVATE void SIMIX_mailbox_exit(void); XBT_PRIVATE smx_mailbox_t SIMIX_mbox_create(const char *name); XBT_PRIVATE void SIMIX_mbox_destroy(smx_mailbox_t mbox); -- 2.20.1