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

int WSReadyParallel(WSENV env,WSLINK *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.

DetailsDetails

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

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include "wstp.h"

/* read data from either of two links */

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

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

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

    result = WSReadyParallel(env, (WSINK *)links, 2, timeout);
    if(result == WSREADYPARALLELERROR)
        { /* unable to check links for data */ }
    else if(result != WSREADYPARALLELTIMEDOUT)
        {
            /* read the link that has data ready */
            if(result == 0)
                /* read lp1 */
            else
                /* read lp2 */
        }
}