WaitNext
WaitNext[{eid1,eid2,…}]
waits until the first evaluation represented by any of the eidi finishes, then returns its result, the corresponding eidi, and the list of remaining eidk.
WaitNext[{eid1,eid2,…},h]
wraps the head h around the result before returning it.
Details
- The eidi are EvaluationObject expressions obtained by submitting expressions for concurrent evaluation using ParallelSubmit.
- WaitNext[{eid1,eid2,…}] returns a list {res,eid,eids}, where res is the result of the finished evaluation, eid is its EvaluationObject, and eids is the list of remaining evaluations.
- The last element in the list produced by WaitNext is suitable for another call to WaitNext.
Examples
open allclose allBasic Examples (1)
Scope (1)
Define a symbol only on the master kernel:
Submit a number of evaluations using this symbol:
Return the next result, but wrap it in Hold first:
Applications (1)
Test for primality, returning $Failed if it is not prime:
Adaptively schedule search jobs until a result has been found or the computation is aborted:
Properties & Relations (2)
ParallelTry is essentially implemented in terms of WaitNext:
Scheduled evaluations no longer needed can be aborted with AbortKernels:
Possible Issues (2)
No more than $KernelCount evaluations are initially run to find the fastest one:
Text
Wolfram Research (2008), WaitNext, Wolfram Language function, https://reference.wolfram.com/language/ref/WaitNext.html.
CMS
Wolfram Language. 2008. "WaitNext." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/WaitNext.html.
APA
Wolfram Language. (2008). WaitNext. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WaitNext.html