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 _extract_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);
+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);
static void SIMIX_comm_start(smx_synchro_t synchro);
void SIMIX_mailbox_exit(void)
* \param type The type of communication we are looking for (comm_send, comm_recv)
* \return The communication synchro if found, NULL otherwise
*/
-static smx_synchro_t _extract_matching_comm(std::deque<smx_synchro_t> *deque, e_smx_comm_type_t type,
- int (*match_fun)(void *, void *,smx_synchro_t), void *this_user_data, smx_synchro_t my_synchro)
+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 *this_user_data, smx_synchro_t my_synchro, bool remove_matching)
{
void* other_user_data = NULL;
(!match_fun || match_fun(this_user_data, other_user_data, synchro)) &&
(!synchro->comm.match_fun || synchro->comm.match_fun(other_user_data, this_user_data, my_synchro))) {
XBT_DEBUG("Found a matching communication synchro %p", synchro);
- deque->erase(it);
+ if (remove_matching)
+ deque->erase(it);
synchro->comm.refcount++;
#if HAVE_MC
synchro->comm.mbox_cpy = synchro->comm.mbox;
* ourself so that the other side also gets a chance of choosing if it wants to match with us.
*
* If it is not found then push our communication into the rendez-vous point */
- smx_synchro_t other_synchro = _extract_matching_comm(mbox->comm_queue, SIMIX_COMM_RECEIVE, match_fun, data, this_synchro);
+ smx_synchro_t other_synchro =
+ _find_matching_comm(mbox->comm_queue, SIMIX_COMM_RECEIVE, match_fun, data, this_synchro, /*remove_matching*/true);
if (!other_synchro) {
other_synchro = this_synchro;
XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication");
//find a match in the already received fifo
- other_synchro = _extract_matching_comm(mbox->done_comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro);
+ other_synchro = _find_matching_comm(mbox->done_comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro,/*remove_matching*/true);
//if not found, assume the receiver came first, register it to the mailbox in the classical way
if (!other_synchro) {
XBT_DEBUG("We have messages in the permanent receive list, but not the one we are looking for, pushing request into fifo");
* ourself so that the other side also gets a chance of choosing if it wants to match with us.
*
* If it is not found then push our communication into the rendez-vous point */
- other_synchro = _extract_matching_comm(mbox->comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro);
+ other_synchro = _find_matching_comm(mbox->comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro,/*remove_matching*/true);
if (!other_synchro) {
- XBT_DEBUG("Receive pushed first %lu", mbox->comm_queue->size());
+ XBT_DEBUG("Receive pushed first %zu", mbox->comm_queue->size());
other_synchro = this_synchro;
SIMIX_mbox_push(mbox, this_synchro);
} else {
smx_synchro_t other_synchro=NULL;
if(mbox->permanent_receiver && ! mbox->done_comm_queue->empty()){
XBT_DEBUG("first check in the permanent recv mailbox, to see if we already got something");
- other_synchro = _extract_matching_comm(mbox->done_comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_synchro);
+ other_synchro =
+ _find_matching_comm(mbox->done_comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_synchro,/*remove_matching*/false);
}
if (!other_synchro){
XBT_DEBUG("check if we have more luck in the normal mailbox");
- other_synchro = _extract_matching_comm(mbox->comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_synchro);
+ other_synchro =
+ _find_matching_comm(mbox->comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_synchro,/*remove_matching*/false);
}
if(other_synchro)
other_synchro->comm.refcount--;