CompareWatches method
The CompareWatches method compares two watches to see whether they are equivalent. This method is equivalent to CompareConnection method.
MPIRC CompareWatches (HMPIADAPT
hAdapter1, HMPIADAPT hAdapter2,MPICOMP
*peComp)
Inputs
- hAdapter1
- Adapter handle
- hAdapter2
- Adapter handle
Outputs
- peComp
- MPI_CMP_EQUAL
- Watches correspond
- MPI_CMP_DIFFER
- Watches do not correspond
- MPI_CMP_LESS
- Watch1 is less than Watch2
- MPI_CMP_GREATER
- Watch1 is greater than Watch2
Returns
Success status
If the adapter does not combine listeners, that is provides Listen as opposed to the CombinedListen method, there is no need to provide a CompareWatches method.
If the method returns MPI_CMP_EQUAL, only one listener thread is created to handle multiple equivalent watches, and the CombinedListen method will be called to handle the multiple combined watches.
If wildcards are part of the command, it might not be possible to combine watches. For example, if there are two commands, to the same queue but one has MID="FRED" and the other MID="*", in some instances, the resource is the same, but not in others.
In this instance, the adapter might handle both events, returning MPI_CMP_EQUAL from this call, or two separate listeners might be spawned, returning MPI_CMP_DIFFER, MPI_CMP_LESS or MPI_CMP_GREATER from this method. The determination of the path to follow can be determined by performance reasons or limitation in the resource's API.
If the sense of ordering in comparisons can be made, the number of comparisons can be reduced because every existing watch does not have to be compared when searching for a valid connection to use.
mpiPropertyGetText(hAdapter1, MYPROP_Q_MGR, 0, &pAdapt1QMgr, &iLen);
mpiPropertyGetText(hAdapter2, MYPROP_Q_MGR, 0, &pAdapt1QMgr, &iLen);
rc = strcmp(pAdapt1QMgr, pAdapt2QMgr);
if (rc == 0)
return MPI_CMP_EQUAL;
else if (rc < 0)
return MPI_CMP_LESS;
else
return MPI_CMP_GREATER;