RECVF(3PVM)

NAME
pvm_recvf - Redefines the comparison function used to accept messages.

SYNOPSIS
C    int (*old)() = pvm_recvf( int (*new)( int bufid, int tid, int tag ))
Fortran    NOT AVAILABLE

DISCUSSION
The routine pvm_recvf defines the comparison function to be used by the pvm_recv, pvm_nrecv, and pvm_probe functions. It is available as a means to customize PVM message passing. pvm_recvf sets a user supplied comparison function to evaluate messages for receiving.

recvf returns the old value of the matching function, or 0 if the old function was the default matcher

pvm_recvf is intended for sophisticated C programmers who understand the function of such routines (like signal) and who require a receive routine that can match on more complex message contexts than the default provides.

MATCHING FUNCTION
The default comparison function evaluates the source and message tag associated with all incoming messages.

PARAMETERS

tid Integer task identifier of sending process supplied by the user.

tag Integer message tag supplied by the user.

bufid
    Integer message buffer identifier.

The matching function should return:
	Value	Action taken
	 < 0	  return immediately with this error code
	   0	  do not pick this message
	   1	  pick this message and do not scan the rest
	 > 1	  pick this highest ranked message after
		scanning them all

Example: Implementing probe with recvf
#include "pvm3.h"
static int foundit = 0;
static int
foo_match(mid, tid, code)
	int mid;
	int tid;
	int code;
{
	int t, c, cc;
	if ((cc = pvm_bufinfo(mid, (int*)0, &c, &t)) < 0)
		return cc;
	if ((tid == -1 || tid == t) && (code == -1 || code == c))
		foundit = 1;
	return 0;
}
int
probe(src, code)
{
	int (*omatch)();
	int cc;
	omatch = pvm_recvf(foo_match);
	foundit = 0;
	if ((cc = pvm_nrecv(src, code)) < 0)
		return cc;
	pvm_recvf(omatch);
	return foundit;
}

ERRORS
No error conditions are returned by pvm_recvf

SEE ALSO
recv(3PVM), nrecv(3PVM), probe(3PVM)