MLReadyParallel (C Function)

MLReadyParallel has been replaced by WSReadyParallel.

int MLReadyParallel(MLENV env,MLINK *links,int n,mltimeval waittime)

takes a list of link objects of length n and waits a timeout period specified by waittime for one of those links to have data ready to read.

Details

  • MLReadyParallel() returns the index into the list of link objects of the link that has data to read. The links are indexed from 0 to (n-1).
  • MLReadyParallel() returns MLREADYPARALLELTIMEDOUT if no link has data to read after the timeout period expires.
  • MLReadyParallel() returns MLREADYPARALLELERROR in the event of an error.
  • To wait for an indefinite period until a link is ready, set waittime to MLINFINITEWAIT.
  • MLReadyParallel() cannot be used as a fine-grained wait mechanism.
  • MLReadyParallel() is analogous to the kernel function LinkReadyQ[{},waittime].
  • MLReadyParallel() is declared in the MathLink header file mathlink.h.

Examples

Basic Examples  (1)

#include "mathlink.h"

/* read data from either of two links */

void f(MLENV env, MLINK lp1, MLINK lp2)
{
    mltimeval timeout;
    MLINK links[2];
    int result;

    timeout.tv_sec = 5;
    timeout.tv_usec = 0;

    links[0] = lp1;
    links[1] = lp2;

    result = MLReadyParallel(env, (MLINK *)links, 2, timeout);
    if(result == MLREADYPARALLELERROR)
        { /* unable to check links for data */ }
    else if(result != MLREADYPARALLELTIMEDOUT)
        {
            /* read the link that has data ready */
            if(result == 0)
                /* read lp1 */
            else
                /* read lp2 */
        }
}