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

acceptEither

Last update:
May 18, 2026
When either this Future or another Future completes successfully first, runs a consuming action on the completing thread with the winning value.

Description

acceptEither is an instance method on a CFML Future. You pass a second Future to race. Whichever stage completes successfully first passes its value to your action. The action runs on the completing thread and performs a side effect (void semantics). A new Future is returned for chaining.
This is the synchronous counterpart to acceptEitherAsync.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.acceptEither(other, action)

Parameters

ParameterDescription
otherRequired. The other Future to race.
actionRequired. A function that accepts the first completed value and performs work (void semantics).

Example

Record the first successful result.

 <cfscript>
    f1 = runAsync(function() { return "winner"; });
    f2 = runAsync(function() {
        sleep(1000);
        return "loser";
    });
    either = f1.acceptEither(f2, function(x) {
        variables.winner = x;
    });
    either.get();
    writeOutput(variables.winner); // winner
</cfscript>
      

See also

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