coldbox.system.async
is also available for all the standalone libraries: WireBox, CacheBox, and LogBox. This means that you can use the async capabilities in ANY ColdFusion (CFML) application, not only ColdBox HMVC applications.Executors
, CompletableFutures
and much more classes from the concurrent packages in the JDK: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/package-summary.html​AsyncManager
. From this manager you will be able to create async pipelines, simple futures, executors and much more.get()
blocking operation, but that is an over simplistic approach to async programming because you are ultimately blocking to get the result.CompletableFuture
API, so the majority of things will apply as well; even Java developers will feel at home. It will allow you to create rich pipelines for creating multiple Futures, chaining, composing and combining results.cfthreads
or even the CFML engine's runAsync()
. Let's start with the first issue, using ColdBox futures instead of cfthread
.cfthread
vs ColdBox Futurescfthreads
are an oversimplification approach to async computations. It allows you to spawn a thread backed by a Java Runnable and then either wait or not for it to complete. You then must use the thread
scope or other scopes to move data around, share data, and well it can get out of hand very quickly. Here are some issues:runAsync()
vs ColdBox FuturesrunAsync()
function. Lucee also has the concept of executing collections in parallel via the each(), map(), filter()
operations as well. However, there is much to be desired in their implementations. Here are a list of deficiencies of their current implementations:java.util.concurrent.Future
and not Completable Futuresthen()
operations. Lucee actually creates a new singleThreadExecutor()
for EVERY then()
operation.ForkJoin
pool the JDK provides. However, the JDK since version 8 provides you a framework for simplifying the execution of asynchronous tasks. It can automatically provide you with a pool of threads and a simple API for assigning tasks or work loads to them. We have bridged the gap between Java and ColdFusion and now allow you to leverage all the functionality of the framework in your applications. You can create many types of executors and customized thread pools, so your work loads can use them.[email protected]
or can be retrieved from the ColdBox main controller: controller.getAsyncManager()
.async()
method that returns to you the instance of the AsyncManager
so you can execute async/parallel operations as well.