WSReadyParallel (C Function)
Details
- WSReadyParallel() 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).
- 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.
Examples
Basic Examples (1)
#include "wstp.h"
/* read data from either of two links */
void f(WSENV env, WSLINK lp1, WSLINK lp2)
{
mltimeval timeout;
WSLINK links[2];
int result;
timeout.tv_sec = 5;
timeout.tv_usec = 0;
links[0] = lp1;
links[1] = lp2;
result = WSReadyParallel(env, (WSLINK *)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 */
}
}