coldbox.system.asyncis 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.
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.
CompletableFutureAPI, 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.
cfthreadsor even the CFML engine's
runAsync(). Let's start with the first issue, using ColdBox futures instead of
cfthreadvs ColdBox Futures
cfthreadsare 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
threadscope 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 Futures
runAsync()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.Futureand not Completable Futures
then()operations. Lucee actually creates a new
ForkJoinpool 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.
async()method that returns to you the instance of the
AsyncManagerso you can execute async/parallel operations as well.