-
-/**
- * \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)
-{
- smx_synchro_t synchro;
-
- /* alloc structures */
- synchro = (smx_synchro_t) xbt_mallocator_get(simix_global->synchro_mallocator);
-
- synchro->type = SIMIX_SYNC_COMMUNICATE;
- synchro->state = SIMIX_WAITING;
-
- /* set communication */
- synchro->comm.type = type;
- synchro->comm.refcount = 1;
- synchro->comm.src_data=NULL;
- synchro->comm.dst_data=NULL;
-
-
-#ifdef HAVE_LATENCY_BOUND_TRACKING
- //initialize with unknown value
- synchro->latency_limited = -1;
-#endif
-
- synchro->category = NULL;
-
- XBT_DEBUG("Create communicate synchro %p", synchro);
- ++smx_total_comms;
-
- return synchro;
-}
-
-/**
- * \brief Destroy a communicate synchro
- * \param synchro The communicate synchro to be destroyed
- */
-void SIMIX_comm_destroy(smx_synchro_t synchro)
-{
- XBT_DEBUG("Destroy synchro %p (refcount: %d), state: %d",
- synchro, synchro->comm.refcount, (int)synchro->state);
-
- if (synchro->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);
- }
- synchro->comm.refcount--;
- if (synchro->comm.refcount > 0)
- return;
- XBT_DEBUG("Really free communication %p; refcount is now %d", synchro,
- synchro->comm.refcount);
-
-#ifdef HAVE_LATENCY_BOUND_TRACKING
- synchro->latency_limited = SIMIX_comm_is_latency_bounded( synchro ) ;
-#endif
-
- xbt_free(synchro->name);
- SIMIX_comm_destroy_internal_actions(synchro);
-
- if (synchro->comm.detached && synchro->state != SIMIX_DONE) {
- /* the communication has failed and was detached:
- * we have to free the buffer */
- if (synchro->comm.clean_fun) {
- synchro->comm.clean_fun(synchro->comm.src_buff);
- }
- synchro->comm.src_buff = NULL;
- }
-
- if(synchro->comm.rdv)
- SIMIX_rdv_remove(synchro->comm.rdv, synchro);
-
- xbt_mallocator_release(simix_global->synchro_mallocator, synchro);
-}
-
-void SIMIX_comm_destroy_internal_actions(smx_synchro_t synchro)
-{
- if (synchro->comm.surf_comm){
-#ifdef HAVE_LATENCY_BOUND_TRACKING
- synchro->latency_limited = SIMIX_comm_is_latency_bounded(synchro);
-#endif
- synchro->comm.surf_comm->unref();
- synchro->comm.surf_comm = NULL;
- }
-
- if (synchro->comm.src_timeout){
- synchro->comm.src_timeout->unref();
- synchro->comm.src_timeout = NULL;
- }
-
- if (synchro->comm.dst_timeout){
- synchro->comm.dst_timeout->unref();
- synchro->comm.dst_timeout = NULL;
- }
-}
-
-void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_process_t src, smx_rdv_t rdv,