/** 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();
*/
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.
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;