/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+#ifdef __cplusplus
+
#ifndef SIMGRID_S4U_MAILBOX_HPP
#define SIMGRID_S4U_MAILBOX_HPP
smx_mailbox_t getInferior() { return inferior_; }
public:
- /** Get the name of that mailbox */
- const char *getName();
/** Retrieve the mailbox associated to the given string */
static Mailbox *byName(const char *name);
private:
- std::string name_;
smx_mailbox_t inferior_;
static boost::unordered_map<std::string, Mailbox *> *mailboxes;
};
}} // namespace simgrid::s4u
+#endif
+
#endif /* SIMGRID_S4U_MAILBOX_HPP */
s4u::Mailbox::Mailbox(const char*name, smx_mailbox_t inferior) {
inferior_ = inferior;
- name_ = name;
mailboxes->insert({name, this});
}
-const char *s4u::Mailbox::getName() {
- return name_.c_str();
-}
s4u::Mailbox *s4u::Mailbox::byName(const char*name) {
s4u::Mailbox *res;
try {
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);
+ xbt_dict_set(mailboxes, name, mbox, NULL);
}
return mbox;
}
{
XBT_DEBUG("mbox free %p", data);
smx_mailbox_t mbox = (smx_mailbox_t) data;
- xbt_free(mbox->name);
delete mbox->comm_queue;
delete mbox->done_comm_queue;
/** @brief Rendez-vous point datatype */
typedef struct s_smx_mailbox {
- char *name;
std::deque<smx_synchro_t> *comm_queue;
void *data;
smx_process_t permanent_receiver; //process which the mailbox is attached to