friend simgrid::s4u::Engine;
friend simgrid::simix::Mailbox;
- smx_mailbox_t pimpl_;
+ simgrid::simix::Mailbox *pimpl_;
Mailbox(smx_mailbox_t mbox): pimpl_(mbox) {}
/** Returns whether the mailbox contains queued communications */
bool empty();
+ /** Returns the first element in the queue, or nullptr if none is there */
+ smx_synchro_t front();
+
/** Declare that the specified process is a permanent receiver on that mailbox
*
* It means that the communications sent to this mailbox will start flowing to its host even before he does a recv().
/***** Rendez-vous points *****/
XBT_PUBLIC(smx_mailbox_t) simcall_mbox_create(const char *name);
-XBT_PUBLIC(smx_synchro_t) simcall_mbox_front(smx_mailbox_t mbox);
XBT_PUBLIC(void) simcall_mbox_set_receiver(smx_mailbox_t mbox , smx_process_t process);
/***** Communication simcalls *****/
int MSG_task_listen_from(const char *alias)
{
msg_mailbox_t mbox = MSG_mailbox_get_by_alias(alias);
- simgrid::kernel::activity::Comm* comm = static_cast<simgrid::kernel::activity::Comm*>(simcall_mbox_front(mbox->getImpl()));
+ simgrid::kernel::activity::Comm* comm = static_cast<simgrid::kernel::activity::Comm*>(mbox->front());
if (!comm)
return -1;
msg_task_t MSG_mailbox_front(msg_mailbox_t mailbox)
{
- simgrid::kernel::activity::Comm* comm = static_cast<simgrid::kernel::activity::Comm*>(simcall_mbox_front(mailbox->getImpl()));
+ simgrid::kernel::activity::Comm* comm = static_cast<simgrid::kernel::activity::Comm*>(mailbox->front());
if (!comm)
return nullptr;
return pimpl_->name;
}
-MailboxPtr Mailbox::byName(const char*name) {
+MailboxPtr Mailbox::byName(const char*name)
+{
// FIXME: there is a race condition here where two actors run Mailbox::byName
// on a non-existent mailbox during the same scheduling round. Both will be
// interrupted in the simcall creating the underlying simix mbox.
return MailboxPtr(&mbox->piface_, true);
}
-bool Mailbox::empty() {
- return nullptr == simcall_mbox_front(pimpl_);
+bool Mailbox::empty()
+{
+ return pimpl_->comm_queue.empty();
+}
+
+smx_synchro_t Mailbox::front()
+{
+ return pimpl_->comm_queue.empty() ? nullptr : pimpl_->comm_queue.front();
}
void Mailbox::setReceiver(Actor* actor) {
return simcall_BODY_mbox_create(name);
}
-/**
- * \ingroup simix_mbox_management
- * \brief returns the communication at the head of the rendez-vous
- * \param mbox The rendez-vous point
- * \return The communication or nullptr if empty
- */
-smx_synchro_t simcall_mbox_front(smx_mailbox_t mbox)
-{
- return mbox->comm_queue.empty() ? nullptr : mbox->comm_queue.front();
-}
-
void simcall_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t process)
{
simcall_BODY_mbox_set_receiver(mbox, process);