- /* two processes may have pushed the same rdv_create simcall at the same time */
- smx_mailbox_t rdv = name ? (smx_mailbox_t) xbt_dict_get_or_null(rdv_points, name) : NULL;
-
- if (!rdv) {
- rdv = xbt_new0(s_smx_rvpoint_t, 1);
- rdv->name = name ? xbt_strdup(name) : NULL;
- rdv->comm_fifo = xbt_fifo_new();
- rdv->done_comm_fifo = xbt_fifo_new();
- rdv->permanent_receiver=NULL;
-
- XBT_DEBUG("Creating a mailbox at %p with name %s", rdv, name);
-
- if (rdv->name)
- xbt_dict_set(rdv_points, rdv->name, rdv, NULL);
+ 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 = (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name);
+
+ if (!mbox) {
+ mbox = xbt_new0(s_smx_mailbox_t, 1);
+ mbox->name = xbt_strdup(name);
+ mbox->comm_queue = new std::deque<smx_synchro_t>();
+ mbox->done_comm_queue = nullptr; // Allocated on need only
+ mbox->permanent_receiver=NULL;
+
+ XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name);
+ xbt_dict_set(mailboxes, mbox->name, mbox, NULL);