Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use std::deque instead of xbt_fifo within mailboxes
[simgrid.git] / src / msg / msg_gos.cpp
index 426f25a..9632b26 100644 (file)
@@ -1,9 +1,9 @@
-/* Copyright (c) 2004-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2004-2016. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "src/simix/smx_private.h" /* MSG_task_listen looks inside the rdv directly. Not clean. */
 #include "msg_private.h"
 #include "mc/mc.h"
 #include "xbt/log.h"
@@ -44,8 +44,7 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task)
 {
   xbt_ex_t e;
   simdata_task_t simdata = task->simdata;
-  msg_process_t self = SIMIX_process_self();
-  simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data(self);
+  simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data();
   e_smx_state_t comp_state;
   msg_error_t status = MSG_OK;
 
@@ -285,7 +284,7 @@ msg_error_t MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, d
 }
 
 /* Internal function used to factorize code between MSG_task_isend_with_matching() and MSG_task_dsend(). */
-static XBT_INLINE msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *alias,
+static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *alias,
                                                      int (*match_fun)(void*,void*, smx_synchro_t),
                                                      void *match_data, void_f_pvoid_t cleanup, int detached)
 {
@@ -297,7 +296,7 @@ static XBT_INLINE msg_comm_t MSG_task_isend_internal(msg_task_t task, const char
   /* Prepare the task to send */
   t_simdata = task->simdata;
   t_simdata->sender = process;
-  t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
+  t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data())->m_host;
 
   if (t_simdata->isused != 0) {
     if (msg_global->debug_multiple_use){
@@ -462,7 +461,7 @@ msg_comm_t MSG_task_irecv(msg_task_t *task, const char *name)
  */
 msg_comm_t MSG_task_irecv_bounded(msg_task_t *task, const char *name, double rate)
 {
-  smx_rdv_t rdv = MSG_mailbox_get_by_alias(name);
+  smx_mailbox_t rdv = MSG_mailbox_get_by_alias(name);
 
   /* FIXME: these functions are not traceable */
   /* Sanity check */
@@ -826,21 +825,8 @@ msg_error_t MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alia
  */
 int MSG_task_listen(const char *alias)
 {
-  return !MSG_mailbox_is_empty(MSG_mailbox_get_by_alias(alias));
-}
-
-/** \ingroup msg_task_usage
- * \brief Check the number of communication actions of a given host pending in a mailbox.
- *
- * \param alias the name of the mailbox to be considered
- * \param host the host to check for communication
- *
- * \return Returns the number of pending communication actions of the host in the given mailbox, 0 if there is no
- *         pending communication actions.
- */
-int MSG_task_listen_from_host(const char *alias, msg_host_t host)
-{
-  return MSG_mailbox_get_count_host_waiting_tasks(MSG_mailbox_get_by_alias(alias), host);
+  smx_mailbox_t mbox = MSG_mailbox_get_by_alias(alias);
+  return !MSG_mailbox_is_empty(mbox) || (mbox->permanent_receiver && !mbox->done_comm_queue->empty());
 }
 
 /** \ingroup msg_task_usage