Whatever message this page gives is out now! Go check it out!

asyncAnyOf

Last update:
May 18, 2026
Returns a Future that completes when the first Future in the array completes, using that result or error.

Description

asyncAnyOf is useful when you want the fastest successful outcome among parallel tasks. The returned Future mirrors the first completing Future: same value on success, or same failure.

Returns

A Future.

Category

Asynchronous programming

Function syntax

asyncAnyOf(futures)

Parameters

ParameterDescription
futuresRequired. An array of Future objects to race. Each element must be a Future.

See also

Example

Return the result from the task that finishes first (from product tests).

 <cfscript>
    f1 = runAsync(function() {
        sleep(1000);
        return "slow";
    });
    f2 = runAsync(function() {
        return "fast";
    });

    anyFuture = asyncAnyOf([f1, f2]);
    result = anyFuture.get();
    writeOutput(result); // fast

</cfscript>  
      

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page