* Creates and registers an Executor according to the passed name, type and options.
* The allowed types are: fixed, cached, single, scheduled with fixed being the default.
* You can then use this executor object to submit tasks for execution and if it's a
* scheduled executor then actually execute scheduled tasks.
* - fixed : By default it will build one with 20 threads on it. Great for multiple task execution and worker processing
* - single : A great way to control that submitted tasks will execute in the order of submission: FIFO
* - cached : An unbounded pool where the number of threads will grow according to the tasks it needs to service. The threads are killed by a default 60 second timeout if not used and the pool shrinks back
* - scheduled : A pool to use for scheduled tasks that can run one time or periodically
* @see https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html
* @name The name of the executor used for registration
* @type The type of executor to build fixed, cached, single, scheduled
* @threads How many threads to assign to the thread scheduler, default is 20
* @debug Add output debugging
* @loadAppContext Load the CFML App contexts or not, disable if not used
* @return The ColdBox Schedule class to work with the schedule: coldbox.system.async.tasks.Executor
Executor function newExecutor(
numeric threads = this.$executors.DEFAULT_THREADS,
boolean loadAppContext = true
* Shortcut to newExecutor( type: "scheduled" )
Executor function newScheduledExecutor(
numeric threads = this.$executors.DEFAULT_THREADS,
boolean loadAppContext = true
* Shortcut to newExecutor( type: "single", threads: 1 )
Executor function newSingleExecutor(
boolean loadAppContext = true
* Shortcut to newExecutor( type: "cached" )
Executor function newCachedExecutor(
numeric threads = this.$executors.DEFAULT_THREADS,
boolean loadAppContext = true
* Get a registered executor registerd in this async manager
* @name The executor name
* @throws ExecutorNotFoundException
* @return The executor object: coldbox.system.async.tasks.Executor
Executor function getExecutor( required name )
* Get the array of registered executors in the system
array function getExecutorNames()
* Verify if an executor exists
* @name The executor name
boolean function hasExecutor( required name )
* Delete an executor from the registry, if the executor has not shutdown, it will shutdown the executor for you
* using the shutdownNow() event
* @name The scheduler name
AsyncManager function deleteExecutor( required name )
* Shutdown an executor or force it to shutdown, you can also do this from the Executor themselves.
* If an un-registered executor name is passed, it will ignore it
* @force Use the shutdownNow() instead of the shutdown() method
AsyncManager function shutdownExecutor( required name, boolean force = false )
* Shutdown all registered executors in the system
* @force By default (false) it gracefullly shuts them down, else uses the shutdownNow() methods
AsyncManager function shutdownAllExecutors( boolean force = false )
* Returns a structure of status maps for every registered executor in the
* manager. This is composed of tons of stats about the executor
* @name The name of the executor to retrieve th status map ONLY!
* @return A struct of metadata about the executor or all executors
struct function getExecutorStatusMap( name )