WSGetYieldFunction()
This feature is not supported on the Wolfram Cloud.

WSYieldFunctionObject WSGetYieldFunction(WSLINK link)
returns the currently installed yield function for the link referenced by link.

DetailsDetails

  • 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.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include "wstp.h"

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

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


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

int f(MLINK 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;    
}