This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
MathLink C Function

MLGetYieldFunction()

MLYieldFunctionObject MLGetYieldFunction(MLINK link)
returns the currently installed yield function for the link referenced by link.
  • 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.
  • MLGetYieldFunction() is declared in the MathLink header file mathlink.h.
#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;    
}