From: Martin Quinson Date: Thu, 21 Apr 2016 19:14:18 +0000 (+0200) Subject: prune some useless code in mailboxes X-Git-Tag: v3_13~34^2~35 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/596294ab8f7a06cf75114739b574a013b60bb368 prune some useless code in mailboxes --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 508348c2de..db7b2d471b 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -366,7 +366,6 @@ XBT_PUBLIC(e_smx_state_t) simcall_process_sleep(double duration); /***** Rendez-vous points *****/ XBT_PUBLIC(smx_mailbox_t) simcall_mbox_create(const char *name); -XBT_PUBLIC(void) simcall_mbox_destroy(smx_mailbox_t mbox); XBT_PUBLIC(smx_mailbox_t) simcall_mbox_get_by_name(const char *name); XBT_PUBLIC(int) simcall_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host); XBT_PUBLIC(smx_synchro_t) simcall_mbox_get_head(smx_mailbox_t mbox); diff --git a/src/msg/msg_mailbox.cpp b/src/msg/msg_mailbox.cpp index 5235ffbafb..11d04eca03 100644 --- a/src/msg/msg_mailbox.cpp +++ b/src/msg/msg_mailbox.cpp @@ -16,11 +16,6 @@ msg_mailbox_t MSG_mailbox_new(const char *alias) return simcall_mbox_create(alias); } -void MSG_mailbox_free(void *mailbox) -{ - simcall_mbox_destroy((msg_mailbox_t)mailbox); -} - int MSG_mailbox_is_empty(msg_mailbox_t mailbox) { return (NULL == simcall_mbox_get_head(mailbox)); diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index efe693ffb8..3edff2f8d9 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -148,11 +148,6 @@ XBT_PRIVATE void MSG_post_create_environment(void); XBT_PRIVATE void MSG_host_add_task(msg_host_t host, msg_task_t task); XBT_PRIVATE void MSG_host_del_task(msg_host_t host, msg_task_t task); -/* @brief MSG_mailbox_free - release a mailbox from the memory. - * Releases a mailbox from the memory but does not remove it from the dictionary. - * @param mailbox The mailbox to release. - */ -XBT_PRIVATE void MSG_mailbox_free(void *mailbox); /********** Tracing **********/ /* declaration of instrumentation functions from msg_task_instr.c */ diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 4406c4ef27..bf6e99b049 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -738,16 +738,6 @@ smx_mailbox_t simcall_mbox_create(const char *name) return simcall_BODY_mbox_create(name); } - -/** - * \ingroup simix_mbox_management - * \brief Destroy a rendez-vous point - * \param mbox The rendez-vous point to destroy - */ -void simcall_mbox_destroy(smx_mailbox_t mbox) -{ - simcall_BODY_mbox_destroy(mbox); -} /** * \ingroup simix_mbox_management * \brief Returns a rendez-vous point knowing its name diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index 63b0c030dd..962e9b9c6a 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -445,13 +445,6 @@ static inline void simcall_mbox_create__set__result(smx_simcall_t simcall, void* simcall->result.dp = result; } -static inline smx_mailbox_t simcall_mbox_destroy__get__mbox(smx_simcall_t simcall) { - return (smx_mailbox_t) simcall->args[0].dp; -} -static inline void simcall_mbox_destroy__set__mbox(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} - static inline smx_mailbox_t simcall_mbox_comm_count_by_host__get__mbox(smx_simcall_t simcall) { return (smx_mailbox_t) simcall->args[0].dp; } diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 88ff816791..fe0f6ac323 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -654,27 +654,6 @@ inline static smx_mailbox_t simcall_BODY_mbox_create(const char* name) { return (smx_mailbox_t) self->simcall.result.dp; } -inline static void simcall_BODY_mbox_destroy(smx_mailbox_t mbox) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_mbox_destroy(mbox); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_MBOX_DESTROY; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) mbox; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - - } - inline static unsigned int simcall_BODY_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host) { smx_process_t self = SIMIX_process_self(); diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 8dca2b7bb2..951f227f35 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -47,7 +47,6 @@ typedef enum { SIMCALL_PROCESS_AUTO_RESTART_SET, SIMCALL_PROCESS_RESTART, SIMCALL_MBOX_CREATE, - SIMCALL_MBOX_DESTROY, SIMCALL_MBOX_COMM_COUNT_BY_HOST, SIMCALL_MBOX_GET_HEAD, SIMCALL_MBOX_SET_RECEIVER, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 0e5b55a328..5e5920942a 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -52,7 +52,6 @@ const char* simcall_names[] = { "SIMCALL_PROCESS_AUTO_RESTART_SET", "SIMCALL_PROCESS_RESTART", "SIMCALL_MBOX_CREATE", - "SIMCALL_MBOX_DESTROY", "SIMCALL_MBOX_COMM_COUNT_BY_HOST", "SIMCALL_MBOX_GET_HEAD", "SIMCALL_MBOX_SET_RECEIVER", @@ -259,11 +258,6 @@ case SIMCALL_MBOX_CREATE: SIMIX_simcall_answer(simcall); break; -case SIMCALL_MBOX_DESTROY: - SIMIX_mbox_destroy((smx_mailbox_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_MBOX_COMM_COUNT_BY_HOST: simcall->result.ui = SIMIX_mbox_comm_count_by_host((smx_mailbox_t) simcall->args[0].dp,(sg_host_t) simcall->args[1].dp); SIMIX_simcall_answer(simcall); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 07cc8628b3..7da760d37c 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -79,7 +79,6 @@ Proc - process_auto_restart_set (void) (process, void*, smx_process_t) (auto_res Func H process_restart (void*, smx_process_t) (process, void*, smx_process_t) Func - mbox_create (void*, smx_mailbox_t) (name, const char*) -Proc - mbox_destroy (void) (mbox, void*, smx_mailbox_t) Func - mbox_comm_count_by_host (unsigned int) (mbox, void*, smx_mailbox_t) (host, void*, sg_host_t) Func - mbox_get_head (void*, smx_synchro_t) (mbox, void*, smx_mailbox_t) Proc - mbox_set_receiver (void) (mbox, void*, smx_mailbox_t) (receiver, void*, smx_process_t) diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index b1cf01d19a..94df88e3e0 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -40,30 +40,23 @@ void SIMIX_mailbox_exit(void) smx_mailbox_t SIMIX_mbox_create(const char *name) { + xbt_assert(name, "Mailboxes must have a name"); /* two processes may have pushed the same mbox_create simcall at the same time */ - smx_mailbox_t mbox = name ? (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name) : NULL; + smx_mailbox_t mbox = (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name); if (!mbox) { mbox = xbt_new0(s_smx_mailbox_t, 1); - mbox->name = name ? xbt_strdup(name) : NULL; + mbox->name = xbt_strdup(name); mbox->comm_fifo = xbt_fifo_new(); mbox->done_comm_fifo = xbt_fifo_new(); mbox->permanent_receiver=NULL; XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name); - - if (mbox->name) - xbt_dict_set(mailboxes, mbox->name, mbox, NULL); + xbt_dict_set(mailboxes, mbox->name, mbox, NULL); } return mbox; } -void SIMIX_mbox_destroy(smx_mailbox_t mbox) -{ - if (mbox->name) - xbt_dict_remove(mailboxes, mbox->name); -} - void SIMIX_mbox_free(void *data) { XBT_DEBUG("mbox free %p", data); diff --git a/src/simix/smx_network_private.h b/src/simix/smx_network_private.h index 0484c4b8f4..80adafe7fb 100644 --- a/src/simix/smx_network_private.h +++ b/src/simix/smx_network_private.h @@ -24,7 +24,6 @@ typedef struct s_smx_mailbox { 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); XBT_PRIVATE smx_mailbox_t SIMIX_mbox_get_by_name(const char *name); XBT_PRIVATE void SIMIX_mbox_remove(smx_mailbox_t mbox, smx_synchro_t comm); XBT_PRIVATE int SIMIX_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host); diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index a6be2497c4..6ef4b1959b 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -460,8 +460,6 @@ void smpi_global_destroy(void) smpi_comm_destroy(process_data[i]->comm_intra); } xbt_os_timer_free(process_data[i]->timer); - simcall_mbox_destroy(process_data[i]->mailbox); - simcall_mbox_destroy(process_data[i]->mailbox_small); xbt_mutex_destroy(process_data[i]->mailboxes_mutex); xbt_free(process_data[i]); }