Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[s4u] Allocate Mailbox on the heap and return MailboxPtr
[simgrid.git] / src / simix / smx_network_private.h
index 039f8f5..ca85abf 100644 (file)
@@ -8,44 +8,53 @@
 #define _SIMIX_NETWORK_PRIVATE_H
 
 #include <deque>
+#include <string>
+
+#include <boost/intrusive_ptr.hpp>
+
 #include <xbt/base.h>
 
+#include <simgrid/s4u/mailbox.hpp>
+
 #include "simgrid/simix.h"
 #include "popping_private.h"
+#include "src/simix/smx_process_private.h"
+
+namespace simgrid {
+namespace simix {
 
 /** @brief Rendez-vous point datatype */
-typedef struct s_smx_mailbox {
-  char *name;
-  std::deque<smx_synchro_t> *comm_queue;
-  smx_process_t permanent_receiver; //process which the mailbox is attached to
-  std::deque<smx_synchro_t> *done_comm_queue;//messages already received in the permanent receive mode
-} s_smx_mailbox_t;
+
+class Mailbox {
+public:
+  Mailbox(const char* name) : mbox_(this), name(xbt_strdup(name)) {}
+  ~Mailbox() {
+    xbt_free(name);
+  }
+
+  simgrid::s4u::Mailbox mbox_;
+  char* name;
+  std::deque<smx_synchro_t> comm_queue;
+  boost::intrusive_ptr<simgrid::simix::Process> permanent_receiver; //process which the mailbox is attached to
+  std::deque<smx_synchro_t> done_comm_queue;//messages already received in the permanent receive mode
+};
+
+}
+}
 
 XBT_PRIVATE void SIMIX_mailbox_exit(void);
 
 XBT_PRIVATE smx_mailbox_t SIMIX_mbox_create(const char *name);
 XBT_PRIVATE smx_mailbox_t SIMIX_mbox_get_by_name(const char *name);
 XBT_PRIVATE void SIMIX_mbox_remove(smx_mailbox_t mbox, smx_synchro_t comm);
-XBT_PRIVATE smx_synchro_t SIMIX_mbox_get_head(smx_mailbox_t mbox);
+
 XBT_PRIVATE void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t proc);
-XBT_PRIVATE smx_process_t SIMIX_mbox_get_receiver(smx_mailbox_t mbox);
 XBT_PRIVATE smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox,
                               void *dst_buff, size_t *dst_buff_size,
-                              int (*)(void *, void *, smx_synchro_t),
+                              int (*match_fun)(void *, void *, smx_synchro_t),
                               void (*copy_data_fun)(smx_synchro_t, void*, size_t),
                               void *data, double rate);
-XBT_PRIVATE void SIMIX_comm_destroy(smx_synchro_t synchro);
-XBT_PRIVATE void SIMIX_comm_destroy_internal_actions(smx_synchro_t synchro);
 XBT_PRIVATE smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int type, int src,
                               int tag, int (*match_fun)(void *, void *, smx_synchro_t), void *data);
-XBT_PRIVATE void SIMIX_post_comm(smx_synchro_t synchro);
-XBT_PRIVATE void SIMIX_comm_cancel(smx_synchro_t synchro);
-XBT_PRIVATE double SIMIX_comm_get_remains(smx_synchro_t synchro);
-XBT_PRIVATE e_smx_state_t SIMIX_comm_get_state(smx_synchro_t synchro);
-XBT_PRIVATE void SIMIX_comm_suspend(smx_synchro_t synchro);
-XBT_PRIVATE void SIMIX_comm_resume(smx_synchro_t synchro);
-XBT_PRIVATE smx_process_t SIMIX_comm_get_src_proc(smx_synchro_t synchro);
-XBT_PRIVATE smx_process_t SIMIX_comm_get_dst_proc(smx_synchro_t synchro);
 
 #endif
-