-smx_action_t SIMIX_rdv_get_request(smx_rdv_t rdv, e_smx_comm_type_t type)
-{
- smx_action_t comm = (smx_action_t)
- xbt_fifo_get_item_content(xbt_fifo_get_first_item(rdv->comm_fifo));
-
- if (comm && comm->comm.type == type) {
- DEBUG0("Communication request found!");
- xbt_fifo_shift(rdv->comm_fifo);
- comm->comm.refcount++;
- comm->comm.rdv = NULL;
- return comm;
+smx_action_t SIMIX_rdv_get_request(smx_rdv_t rdv, e_smx_comm_type_t type,
+ int (*match_fun)(void *, void *), void *data)
+{
+ smx_action_t req;
+ xbt_fifo_item_t item;
+ void* req_data = NULL;
+
+ xbt_fifo_foreach(rdv->comm_fifo, item, req, smx_action_t){
+ if(req->comm.type == SIMIX_COMM_SEND) {
+ req_data = req->comm.src_data;
+ } else if(req->comm.type == SIMIX_COMM_RECEIVE) {
+ req_data = req->comm.dst_data;
+ }
+ if (req->comm.type == type && (!match_fun || match_fun(data, req_data))) {
+ xbt_fifo_remove_item(rdv->comm_fifo, item);
+ xbt_fifo_free_item(item);
+ req->comm.refcount++;
+ req->comm.rdv = NULL;
+ return req;
+ }