XBT_DEBUG("Create communicate synchro %p", this);
}
-void simgrid::simix::Comm::suspend() {
+void simgrid::simix::Comm::suspend()
+{
/* FIXME: shall we suspend also the timeout synchro? */
if (surf_comm)
surf_comm->suspend();
}
-void simgrid::simix::Comm::resume() {
+void simgrid::simix::Comm::resume()
+{
/*FIXME: check what happen with the timeouts */
if (surf_comm)
surf_comm->resume();
/* in the other case, the synchro were not really suspended yet, see SIMIX_comm_suspend() and SIMIX_comm_start() */
}
-void simgrid::simix::Comm::cancel() {
+void simgrid::simix::Comm::cancel()
+{
/* if the synchro is a waiting state means that it is still in a mbox */
/* so remove from it and delete it */
if (state == SIMIX_WAITING) {
}
/** @brief get the amount remaining from the communication */
-double simgrid::simix::Comm::remains() {
+double simgrid::simix::Comm::remains()
+{
switch (state) {
case SIMIX_RUNNING:
break;
}
}
+
+/** @brief This is part of the cleanup process, probably an internal command */
+void simgrid::simix::Comm::cleanupSurf()
+{
+ if (surf_comm){
+ surf_comm->unref();
+ surf_comm = NULL;
+ }
+
+ if (src_timeout){
+ src_timeout->unref();
+ src_timeout = NULL;
+ }
+
+ if (dst_timeout){
+ dst_timeout->unref();
+ dst_timeout = NULL;
+ }
+}
void resume();
void cancel();
double remains();
+ void cleanupSurf(); // FIXME: make me protected
e_smx_comm_type_t type; /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
smx_mailbox_t mbox = nullptr; /* Rendez-vous where the comm is queued */
(used as garbage collector)) */
#endif
int refcount = 1; /* Number of processes involved in the cond */
- int detached = 0; /* If detached or not */
+ bool detached = false; /* 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 *dst_buff = nullptr;
size_t src_buff_size;
size_t *dst_buff_size;
- unsigned copied = 0; /* whether the data were already copied */
+ bool copied = false; /* whether the data were already copied */
void* src_data; /* User data associated to communication */
void* dst_data;
return;
XBT_DEBUG("Really free communication %p; refcount is now %d", comm, comm->refcount);
- SIMIX_comm_destroy_internal_actions(synchro);
+ comm->cleanupSurf();
if (comm->detached && comm->state != SIMIX_DONE) {
/* the communication has failed and was detached:
delete comm;
}
-void SIMIX_comm_destroy_internal_actions(smx_synchro_t synchro)
-{
- simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
- if (comm->surf_comm){
- comm->surf_comm->unref();
- comm->surf_comm = NULL;
- }
-
- if (comm->src_timeout){
- comm->src_timeout->unref();
- comm->src_timeout = NULL;
- }
-
- if (comm->dst_timeout){
- comm->dst_timeout->unref();
- comm->dst_timeout = NULL;
- }
-}
-
void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_process_t src, smx_mailbox_t mbox,
double task_size, double rate,
void *src_buff, size_t src_buff_size,
void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_synchro_t synchro, double timeout)
{
- /* the simcall may be a wait, a send or a recv */
- surf_action_t sleep;
-
/* Associate this simcall to the wait synchro */
XBT_DEBUG("simcall_HANDLER_comm_wait, %p", synchro);
if (synchro->state != SIMIX_WAITING && synchro->state != SIMIX_RUNNING) {
SIMIX_comm_finish(synchro);
} else { /* if (timeout >= 0) { we need a surf sleep action even when there is no timeout, otherwise surf won't tell us when the host fails */
- sleep = surf_host_sleep(simcall->issuer->host, timeout);
+ surf_action_t sleep = surf_host_sleep(simcall->issuer->host, timeout);
sleep->setData(synchro);
simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure",
sg_host_get_name(sender), sg_host_get_name(receiver));
comm->state = SIMIX_LINK_FAILURE;
- SIMIX_comm_destroy_internal_actions(synchro);
+ comm->cleanupSurf();
}
/* If any of the process is suspend, create the synchro but stop its execution,
comm, (int)comm->state, comm->src_proc, comm->dst_proc, comm->detached);
/* destroy the surf actions associated with the Simix communication */
- SIMIX_comm_destroy_internal_actions(comm);
+ comm->cleanupSurf();
/* if there are simcalls associated with the synchro, then answer them */
if (xbt_fifo_size(synchro->simcalls)) {
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 void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t proc);
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,
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);