User`s guide
fetchNext
11-87
fetchNext
Retrieve next available unread FevalFuture outputs
Syntax
[idx,B1,B2,...,Bn] = fetchNext(F)
[idx,B1,B2,...,Bn] = fetchNext(F,TIMEOUT)
Description
[idx,B1,B2,...,Bn] = fetchNext(F) waits for an unread FevalFuture in the array
of futures F to finish, and then returns the index of that future in array F as idx, along
with the future’s results in B1,B2,...,Bn. Before this call, the 'Read' property of the
particular future is false; afterward it is true.
[idx,B1,B2,...,Bn] = fetchNext(F,TIMEOUT) waits no longer than TIMEOUT
seconds for a result to become available. If the timeout expires before any result becomes
available, all output arguments are empty.
If there are no futures in F whose 'Read' property is false, then an error is
reported. You can check whether there are any unread futures using anyUnread =
~all([F.Read]).
If the element of F which has become finished encountered an error during execution,
that error will be thrown by fetchNext. However, that future’s 'Read' property is set
true, so that any subsequent calls to fetchNext can proceed.
Examples
Request several function evaluations, and update a progress bar while waiting for
completion.
N = 100;
for idx = N:-1:1
% Compute the rank of N magic squares
F(idx) = parfeval(@rank,1,magic(idx));