OpenersNotesSection(Spacer1)Details

Some WSTP 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 WSTP will automatically make calls to the yield function while it blocks.

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

WSGetYieldFunction() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "wstp.h"

int AppYieldFunction1 (WSLINK mlp, WSYieldParameters yp)
{
	/* ... */
	return 0;
}

int AppYieldFunction2 (WSLINK mlp, WSYieldParameters yp)
{
	/* ... */
	return 0;
}


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

int f(WSLINK lp)
{
	WSYieldFunctionObject yf;

	yf = WSGetYieldFunction(lp);
	if(yf == (WSYieldFunctionObject)AppYieldFunction1) return 1;
	else if(yf == (WSYieldFunctionObject)AppYieldFunction2) return 2;
	else if(yf == (WSYieldFunctionObject)0) return 0;

	return -1;	
}

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

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[Low-Level WSTP Operations, paclet:guide/LowLevelWSTPOperations])}})}})