Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
turn SIMIX_comm_new() into a proper constructor
[simgrid.git] / src / simix / smx_network.cpp
index f913e7f..82e37ad 100644 (file)
@@ -20,7 +20,6 @@ static xbt_dict_t mailboxes = xbt_dict_new_homogeneous(SIMIX_mbox_free);
 
 static void SIMIX_waitany_remove_simcall_from_actions(smx_simcall_t simcall);
 static void SIMIX_comm_copy_data(smx_synchro_t comm);
-static smx_synchro_t SIMIX_comm_new(e_smx_comm_type_t type);
 static inline void SIMIX_mbox_push(smx_mailbox_t mbox, smx_synchro_t comm);
 static smx_synchro_t _find_matching_comm(std::deque<smx_synchro_t> *deque, e_smx_comm_type_t type,
     int (*match_fun)(void *, void *,smx_synchro_t), void *user_data, smx_synchro_t my_synchro, bool remove_matching);
@@ -172,25 +171,6 @@ static smx_synchro_t _find_matching_comm(std::deque<smx_synchro_t> *deque, e_smx
 /*                          Communication synchros                            */
 /******************************************************************************/
 
-/**
- *  \brief Creates a new communicate synchro
- *  \param type The direction of communication (comm_send, comm_recv)
- *  \return The new communicate synchro
- */
-smx_synchro_t SIMIX_comm_new(e_smx_comm_type_t type)
-{
-  simgrid::simix::Comm *comm = new simgrid::simix::Comm();
-  comm->state = SIMIX_WAITING;
-  comm->type = type;
-  comm->refcount = 1;
-  comm->src_data=NULL;
-  comm->dst_data=NULL;
-
-  XBT_DEBUG("Create communicate synchro %p", comm);
-
-  return comm;
-}
-
 /**
  *  \brief Destroy a communicate synchro
  *  \param synchro The communicate synchro to be destroyed
@@ -203,8 +183,7 @@ void SIMIX_comm_destroy(smx_synchro_t synchro)
 
   if (comm->refcount <= 0) {
     xbt_backtrace_display_current();
-    xbt_die("The refcount of comm %p is already 0 before decreasing it. "
-            "That's a bug! If you didn't test and/or wait the same communication twice in your code, then the bug is SimGrid's...", synchro);
+    xbt_die("This comm has a negative refcount! You must not call test() or wait() more than once on a given communication.");
   }
   comm->refcount--;
   if (comm->refcount > 0)
@@ -270,7 +249,7 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr
   XBT_DEBUG("send from %p", mbox);
 
   /* Prepare a synchro describing us, so that it gets passed to the user-provided filter of other side */
-  smx_synchro_t this_synchro = SIMIX_comm_new(SIMIX_COMM_SEND);
+  smx_synchro_t this_synchro = new simgrid::simix::Comm(SIMIX_COMM_SEND);
 
   /* Look for communication synchro matching our needs. We also provide a description of
    * ourself so that the other side also gets a chance of choosing if it wants to match with us.
@@ -365,7 +344,7 @@ smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void
     void *data, double rate)
 {
   XBT_DEBUG("recv from %p %p", mbox, mbox->comm_queue);
-  smx_synchro_t this_synchro = SIMIX_comm_new(SIMIX_COMM_RECEIVE);
+  smx_synchro_t this_synchro = new simgrid::simix::Comm(SIMIX_COMM_RECEIVE);
 
   smx_synchro_t other_synchro;
   //communication already done, get it inside the fifo of completed comms
@@ -450,10 +429,10 @@ smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int
   smx_synchro_t this_synchro;
   int smx_type;
   if(type == 1){
-    this_synchro=SIMIX_comm_new(SIMIX_COMM_SEND);
+    this_synchro = new simgrid::simix::Comm(SIMIX_COMM_SEND);
     smx_type = SIMIX_COMM_RECEIVE;
   } else{
-    this_synchro=SIMIX_comm_new(SIMIX_COMM_RECEIVE);
+    this_synchro = new simgrid::simix::Comm(SIMIX_COMM_RECEIVE);
     smx_type = SIMIX_COMM_SEND;
   } 
   smx_synchro_t other_synchro=NULL;
@@ -833,24 +812,6 @@ void SIMIX_post_comm(smx_synchro_t synchro)
   }
 }
 
-void SIMIX_comm_cancel(smx_synchro_t synchro)
-{
-  simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
-
-  /* if the synchro is a waiting state means that it is still in a mbox */
-  /* so remove from it and delete it */
-  if (comm->state == SIMIX_WAITING) {
-    SIMIX_mbox_remove(comm->mbox, synchro);
-    comm->state = SIMIX_CANCELED;
-  }
-  else if (!MC_is_active() /* when running the MC there are no surf actions */
-           && !MC_record_replay_is_active()
-           && (comm->state == SIMIX_READY || comm->state == SIMIX_RUNNING)) {
-
-    comm->surf_comm->cancel();
-  }
-}
-
 /************* synchro Getters **************/
 
 /**