Synchro();
virtual ~Synchro();
e_smx_state_t state; /* State of the synchro */
- char *name; /* synchro name if any */
+ char *name = nullptr; /* synchro name if any */
xbt_fifo_t simcalls; /* List of simcalls waiting for this synchro */
char *category = nullptr; /* For instrumentation */
#include "simgrid/modelchecker.h"
#include "src/mc/mc_replay.h"
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_network);
+simgrid::simix::Comm::Comm(e_smx_comm_type_t _type) {
+ state = SIMIX_WAITING;
+ this->type = _type;
+ refcount = 1;
+ src_data=NULL;
+ dst_data=NULL;
+
+ XBT_DEBUG("Create communicate synchro %p", this);
+}
void simgrid::simix::Comm::suspend() {
/* FIXME: shall we suspend also the timeout synchro? */
if (surf_comm)
XBT_PUBLIC_CLASS Comm : public Synchro {
public:
+ Comm(e_smx_comm_type_t type);
void suspend();
void resume();
void cancel();
e_smx_comm_type_t type; /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
- smx_mailbox_t mbox; /* Rendez-vous where the comm is queued */
+ smx_mailbox_t mbox = nullptr; /* Rendez-vous where the comm is queued */
#if HAVE_MC
smx_mailbox_t mbox_cpy; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
(comm.mbox set to NULL when the communication is removed from the mailbox
(used as garbage collector)) */
#endif
- int refcount; /* Number of processes involved in the cond */
- int detached; /* If detached or not */
+ int refcount = 1; /* Number of processes involved in the cond */
+ int detached = 0; /* If detached or not */
void (*clean_fun)(void*); /* Function to clean the detached src_buf if something goes wrong */
int (*match_fun)(void*,void*,smx_synchro_t); /* Filter function used by the other side. It is used when
void (*copy_data_fun) (smx_synchro_t, void*, size_t);
/* Surf action data */
- surf_action_t surf_comm; /* The Surf communication action encapsulated */
- surf_action_t src_timeout; /* Surf's actions to instrument the timeouts */
- surf_action_t dst_timeout; /* Surf's actions to instrument the timeouts */
- smx_process_t src_proc;
- smx_process_t dst_proc;
+ surf_action_t surf_comm = nullptr; /* The Surf communication action encapsulated */
+ surf_action_t src_timeout = nullptr; /* Surf's actions to instrument the timeouts */
+ surf_action_t dst_timeout = nullptr; /* Surf's actions to instrument the timeouts */
+ smx_process_t src_proc = nullptr;
+ smx_process_t dst_proc = nullptr;
double rate;
double task_size;
/* Data to be transfered */
- void *src_buff;
- void *dst_buff;
+ void *src_buff = nullptr;
+ void *dst_buff = nullptr;
size_t src_buff_size;
size_t *dst_buff_size;
- unsigned copied:1; /* whether the data were already copied */
+ unsigned copied = 0; /* whether the data were already copied */
void* src_data; /* User data associated to communication */
void* dst_data;
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);
/* 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
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.
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
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;
if (!AX_surfxml_ASroute_src) FAIL("Required attribute `src' not set for `ASroute' element.");
LEAVE; STag_surfxml_ASroute(); surfxml_pcdata_ix = 0; ETag_surfxml_ASroute(); popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_AS: case S_surfxml_AS_3: case S_surfxml_AS_5: case S_surfxml_AS_6: SET(S_surfxml_AS_6); break;
- case S_surfxml_AS_1: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_8: SET(S_surfxml_AS_8); break;
+ case S_surfxml_AS_1: case S_surfxml_AS_3: case S_surfxml_AS_5: case S_surfxml_AS_6: SET(S_surfxml_AS_6); break;
+ case S_surfxml_AS: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_8: SET(S_surfxml_AS_8); break;
}
}
YY_BREAK
ETag_surfxml_ASroute();
popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_AS: case S_surfxml_AS_3: case S_surfxml_AS_5: case S_surfxml_AS_6: SET(S_surfxml_AS_6); break;
- case S_surfxml_AS_1: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_8: SET(S_surfxml_AS_8); break;
+ case S_surfxml_AS_1: case S_surfxml_AS_3: case S_surfxml_AS_5: case S_surfxml_AS_6: SET(S_surfxml_AS_6); break;
+ case S_surfxml_AS: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_8: SET(S_surfxml_AS_8); break;
}
}
YY_BREAK