+/** @brief Find a mailox from its name or create one if it does not exist) */
+Mailbox* Engine::mailbox_by_name_or_create(const std::string& name) const
+{
+ /* two actors may have pushed the same mbox_create simcall at the same time */
+ kernel::activity::MailboxImpl* mbox = kernel::actor::simcall([&name, this] {
+ auto m = pimpl->mailboxes_.emplace(name, nullptr);
+ if (m.second) {
+ m.first->second = new kernel::activity::MailboxImpl(name);
+ XBT_DEBUG("Creating a mailbox at %p with name %s", m.first->second, name.c_str());
+ }
+ return m.first->second;
+ });
+ return mbox->get_iface();
+}
+