-/**
- * \brief Pushes a communication synchro into a rendez-vous point
- * \param mbox The mailbox
- * \param synchro The communication synchro
+namespace simgrid {
+namespace simix {
+/** @brief Returns the mailbox of that name, or nullptr */
+MailboxImpl* MailboxImpl::byNameOrNull(const char* name)
+{
+ return static_cast<smx_mailbox_t>(xbt_dict_get_or_null(mailboxes, name));
+}
+/** @brief Returns the mailbox of that name, newly created on need */
+MailboxImpl* MailboxImpl::byNameOrCreate(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 = static_cast<smx_mailbox_t>(xbt_dict_get_or_null(mailboxes, name));
+ if (!mbox) {
+ mbox = new simgrid::simix::MailboxImpl(name);
+ XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name);
+ xbt_dict_set(mailboxes, mbox->name_, mbox, nullptr);
+ }
+ return mbox;
+}
+/** @brief Pushes a communication activity into a mailbox
+ * @param activity What to add