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

Synchronous functions

Last update:
May 18, 2026
Category index for ColdFusion Future methods that run follow-up work on the completing thread: sync chaining, dual-future coordination, race helpers, and sync completion or error handling.

About this category

These entries are Future instance methods. You call them on a value such as one returned from runAsync. After the previous stage completes, the callback you pass runs on the completing thread (the thread that completes the prior stage), not on the separate async executor used by Async method names.
Synchronous stages add less scheduling overhead and keep ordering tight with the completion of the prior step. They are a good default for small, fast work (mapping a number, building a struct, short logging). If the follow-up might block or run for a long time, prefer the matching Asynchronous functions topic and the Async methods so the completing thread returns to the pool quickly.

How this fits CFML async code

ColdFusion still supports runAsync and fluent then and error on futures for existing applications. The methods listed here align with CompletableFuture naming and behavior: they compose pipelines and error paths in fine-grained steps alongside those entry points.
Each method name below links to a dedicated reference topic with syntax, parameters, and examples. The same topics appear under this map in the groups Chaining — sync (completing thread) and Completion and errors — sync.

Chaining — sync (completing thread)

Single-result chaining, dual-future merge, and either-first (race) patterns when follow-ups run synchronously after completion.
thenApply — map the successful result to a new value on the completing thread.
thenAccept — run a side-effect callback with the result on the completing thread.
thenRun — run a parameterless action on the completing thread after success.
thenCompose — flat-map to another Future on the completing thread.
thenCombine — when two futures succeed, combine both results on the completing thread.
thenAcceptBoth — side effect with both results on the completing thread.
runAfterBoth — parameterless action after both futures succeed.
applyToEither — map the first successful completion from a race.
acceptEither — side effect with the first successful completion from a race.
runAfterEither — parameterless action after either future succeeds first.

Completion and errors — sync

Observe completion, map success and failure into one value, or recover from errors while callbacks run on the completing thread.
whenComplete — observe completion (value and error) on the completing thread.
handle — fold result or error into a new value on the completing thread.
exceptionally — recover from failure with a value on the completing thread.
exceptionallyCompose — recover from failure with a new Future on the completing thread.

Example

Short sync chain after runAsync: map twice on the completing thread, then read the result.
f = runAsync(function() { return 5; });f = f.thenApply(function(x) { return x * 2; });f = f.thenApply(function(x) { return x + 3; });writeOutput(f.get()); // 13

Quick reference table

MethodSummary
thenApplySync map after success.
thenAcceptSync side effect with the value.
thenRunSync parameterless follow-up.
thenComposeSync flat-map to another Future.
thenCombineSync merge of two successful results.
thenAcceptBothSync side effect with both values.
runAfterBothSync action after both complete.
applyToEitherSync map of the first completing value.
acceptEitherSync consume the first completing value.
runAfterEitherSync action after either completes.
whenCompleteSync observe completion.
handleSync fold result or error into a new value.
exceptionallySync recover from failure with a value.
exceptionallyComposeSync recover from failure with a Future.

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