WSGetYieldFunction (C Function)

WSYieldFunctionObject WSGetYieldFunction(WSLINK link)

returns the currently installed yield function for the link referenced by link.

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 (WSYieldFunctionObject)0.
  • WSGetYieldFunction() is declared in the WSTP header file wstp.h.

Examples

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;    
}