Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add Mailox_listen_from
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 30 Mar 2020 13:18:32 +0000 (15:18 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 30 Mar 2020 13:18:32 +0000 (15:18 +0200)
include/simgrid/s4u/Mailbox.hpp
src/msg/msg_task.cpp
src/s4u/s4u_Mailbox.cpp

index 5c02b70..f60c070 100644 (file)
@@ -45,6 +45,9 @@ public:
   /** Check if there is a communication going on in a mailbox. */
   bool listen();
 
+  /** Look if there is a communication going on in a mailbox and return the PID of the sender actor */
+  aid_t listen_from();
+
   /** Check if there is a communication ready to be consumed from a mailbox. */
   bool ready();
 
index 139ebc8..032624f 100644 (file)
@@ -637,13 +637,7 @@ msg_comm_t MSG_task_irecv_bounded(msg_task_t* task, const char* name, double rat
  */
 int MSG_task_listen_from(const char* alias)
 {
-  /* looks inside the rdv directly. Not clean. */
-  simgrid::kernel::activity::CommImplPtr comm = simgrid::s4u::Mailbox::by_name(alias)->front();
-
-  if (comm && comm->src_actor_)
-    return comm->src_actor_->get_pid();
-  else
-    return -1;
+  return simgrid::s4u::Mailbox::by_name(alias)->listen_from();
 }
 
 /** @brief Destroys the given task.
index 190dd9d..abbf92e 100644 (file)
@@ -44,6 +44,15 @@ bool Mailbox::listen()
   return not this->empty() || (pimpl_->permanent_receiver_ && not pimpl_->done_comm_queue_.empty());
 }
 
+aid_t Mailbox::listen_from()
+{
+  kernel::activity::CommImplPtr comm = front();
+  if (comm && comm->src_actor_)
+    return comm->src_actor_->get_pid();
+  else
+    return -1;
+}
+
 bool Mailbox::ready()
 {
   bool comm_ready = false;