-
-/**
- * \brief Checks if there is a communication synchro queued in a fifo matching our needs, but leave it there
- * \param type The type of communication we are looking for (comm_send, comm_recv)
- * \return The communication synchro if found, NULL otherwise
- */
-smx_synchro_t SIMIX_fifo_probe_comm(xbt_fifo_t fifo, e_smx_comm_type_t type,
- int (*match_fun)(void *, void *,smx_synchro_t),
- void *this_user_data, smx_synchro_t my_synchro)
-{
- smx_synchro_t synchro;
- xbt_fifo_item_t item;
- void* other_user_data = NULL;
-
- xbt_fifo_foreach(fifo, item, synchro, smx_synchro_t) {
- if (synchro->comm.type == SIMIX_COMM_SEND) {
- other_user_data = synchro->comm.src_data;
- } else if (synchro->comm.type == SIMIX_COMM_RECEIVE) {
- other_user_data = synchro->comm.dst_data;
- }
- if (synchro->comm.type == type &&
- (!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);
- synchro->comm.refcount++;
-
- return synchro;
- }
- XBT_DEBUG("Sorry, communication synchro %p does not match our needs:"
- " its type is %d but we are looking for a comm of type %d (or maybe the filtering didn't match)",
- synchro, (int)synchro->comm.type, (int)type);
- }
- XBT_DEBUG("No matching communication synchro found");
- return NULL;
-}