OpenersNotesSection(Spacer1)Details

Some MathLink API calls will block until data is available to read or space is available for writing. If an application needs to perform other useful processing during that blocking time, the application can install a yield function for the link and MathLink will automatically make calls to the yield function while it blocks.

If link does not have a yield function installed, MLGetYieldFunction() returns ((NonWLLink[MLYieldFunctionObject, paclet:ref/c/MLYieldFunctionObject]))0.

MLGetYieldFunction() is declared in the MathLink header file (RefLink[mathlink.h, paclet:ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"

int AppYieldFunction1 (MLINK mlp, MLYieldParameters yp)
{
	/* ... */
	return 0;
}

int AppYieldFunction2 (MLINK mlp, MLYieldParameters yp)
{
	/* ... */
	return 0;
}


/* check which yield function is installed in a link */

int f(MLINK lp)
{
	MLYieldFunctionObject yf;

	yf = MLGetYieldFunction(lp);
	if(yf == (MLYieldFunctionObject)AppYieldFunction1) return 1;
	else if(yf == (MLYieldFunctionObject)AppYieldFunction2) return 2;
	else if(yf == (MLYieldFunctionObject)0) return 0;

	return -1;	
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLSetYieldFunction(), paclet:ref/c/MLSetYieldFunction])}})}})