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 all

Basic Examples  (1)

Submit a number of integer factorizations:

Wait until the fastest one is done:

Wait for the next one:

Finally, wait for all remaining ones:

Scope  (1)

Define a symbol only on the master kernel:

Submit a number of evaluations using this symbol:

Return the first result:

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:

Each evaluation should be waited for exactly once:

One of the evaluation objects has already completed:

Wolfram Research (2008), WaitNext, Wolfram Language function, https://reference.wolfram.com/language/ref/WaitNext.html.

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

BibTeX

@misc{reference.wolfram_2024_waitnext, author="Wolfram Research", title="{WaitNext}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/WaitNext.html}", note=[Accessed: 03-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_waitnext, organization={Wolfram Research}, title={WaitNext}, year={2008}, url={https://reference.wolfram.com/language/ref/WaitNext.html}, note=[Accessed: 03-December-2024 ]}