cachebox.system.async.executors

Class Executor

lucee.Component
    extended by cachebox.system.async.executors.Executor
Direct Known Subclasses:
ScheduledExecutor

This is the ColdBox Executor class which connects your code to the Java Scheduling services to execute tasks on. The native property models the injected Java executor which can be: - Fixed - Cached - Single - Scheduled

Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
    Property Summary
    type property default serializable required
    any name
          The human name of this executor.

    • access = public
    • returntype = any
    true false
    any native
          The native Java executor class modeled in this executor.

    • access = public
    • returntype = any
    true false
    numeric shutdownTimeout
          The default timeout the executor service will wait for all of it's tasks to shutdown.

    • access = public
    • returntype = any
    30 true false
    Constructor Summary
    init(any name, any executor, [boolean debug='false'], [boolean loadAppContext='true'], [numeric shutdownTimeout='30'])
          Constructor.
    Method Summary
    boolean awaitTermination(numeric timeout, [any timeUnit='seconds'])
         Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or.
    Executor err(any var)
         Utility to send to output to the error stream.
    numeric getActiveCount()
         Returns the approximate number of threads that are actively executing tasks.
    numeric getCompletedTaskCount()
         Returns the approximate total number of tasks that have completed execution.
    numeric getCorePoolSize()
         Returns the core number of threads.
    numeric getLargestPoolSize()
         Returns the largest number of threads that have ever simultaneously been in the pool.
    numeric getMaximumPoolSize()
         Returns the maximum allowed number of threads.
    string getName()
    string getNative()
    numeric getPoolSize()
         Returns the current number of threads in the pool.
    any getQueue()
         Returns the task queue used by this executor.
    string getShutdownTimeout()
    struct getStats()
         Our very own stats struct map to give you a holistic view of the schedule.
    numeric getTaskCount()
         Returns the approximate total number of tasks that have ever been scheduled for execution.
    boolean isShutdown()
         Returns true if this executor has been shut down.
    boolean isTerminated()
         Returns true if all tasks have completed following shut down.
    boolean isTerminating()
         Returns true if this executor is in the process of terminating after shutdown() or shutdownNow() but has.
    Executor out(any var)
         Utility to send to output to the output stream.
    any setName(any name)
    any setNative(any native)
    any setShutdownTimeout(numeric shutdownTimeout)
    Executor shutdown()
         Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
    Executor shutdownAndAwaitTermination([numeric timeout='[runtime expression]'])
         Shuts down the executor in two phases, first by calling the shutdown() and rejecting all incoming tasks.
    any shutdownNow()
         Attempts to stop all actively executing tasks, halts the processing of.
    cachebox.system.async.executors.FutureTask submit(any callable, [any method='run'])
         Submit a task into the executor which can return a result if any.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init(any name, any executor, [boolean debug='false'], [boolean loadAppContext='true'], [numeric shutdownTimeout='30'])

    Constructor

    Parameters:
    name - The name of the executor
    executor - The native executor class
    debug - Add output debugging
    loadAppContext - Load the CFML App contexts or not, disable if not used
    shutdownTimeout - The timeout in seconds to use when gracefully shutting down the executor. Defaults to 30 seconds.

    Property Detail

    name

    property any name

    The human name of this executor

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    native

    property any native

    The native Java executor class modeled in this executor

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    shutdownTimeout

    property numeric shutdownTimeout = [30]

    The default timeout the executor service will wait for all of it's tasks to shutdown. The default is 30 seconds. This number is in seconds.

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    Method Detail

    awaitTermination

    public boolean awaitTermination(numeric timeout, [any timeUnit='seconds'])

    Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

    Parameters:
    timeout - The maximum time to wait
    timeUnit - The time unit to use, available units are: days, hours, microseconds, milliseconds, minutes, nanoseconds, and seconds. The default is seconds
    Returns:
    true if all tasks have completed following shut down
    Throws:
    InterruptedException - if interrupted while waiting

    err

    public Executor err(any var)

    Utility to send to output to the error stream

    Parameters:
    var - Variable/Message to send

    getActiveCount

    public numeric getActiveCount()

    Returns the approximate number of threads that are actively executing tasks.


    getCompletedTaskCount

    public numeric getCompletedTaskCount()

    Returns the approximate total number of tasks that have completed execution.


    getCorePoolSize

    public numeric getCorePoolSize()

    Returns the core number of threads.


    getLargestPoolSize

    public numeric getLargestPoolSize()

    Returns the largest number of threads that have ever simultaneously been in the pool.


    getMaximumPoolSize

    public numeric getMaximumPoolSize()

    Returns the maximum allowed number of threads.


    getName

    public string getName()


    getNative

    public string getNative()


    getPoolSize

    public numeric getPoolSize()

    Returns the current number of threads in the pool.


    getQueue

    public any getQueue()

    Returns the task queue used by this executor.


    getShutdownTimeout

    public string getShutdownTimeout()


    getStats

    public struct getStats()

    Our very own stats struct map to give you a holistic view of the schedule and it's executor

    Returns:
    struct of data about the executor and the schedule

    getTaskCount

    public numeric getTaskCount()

    Returns the approximate total number of tasks that have ever been scheduled for execution.


    isShutdown

    public boolean isShutdown()

    Returns true if this executor has been shut down.


    isTerminated

    public boolean isTerminated()

    Returns true if all tasks have completed following shut down.


    isTerminating

    public boolean isTerminating()

    Returns true if this executor is in the process of terminating after shutdown() or shutdownNow() but has not completely terminated.


    out

    public Executor out(any var)

    Utility to send to output to the output stream

    Parameters:
    var - Variable/Message to send

    setName

    public any setName(any name)

    Parameters:
    name

    setNative

    public any setNative(any native)

    Parameters:
    native

    setShutdownTimeout

    public any setShutdownTimeout(numeric shutdownTimeout)

    Parameters:
    shutdownTimeout

    shutdown

    public Executor shutdown()

    Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down. This method does not wait for previously submitted tasks to complete execution. Use awaitTermination to do that.


    shutdownAndAwaitTermination

    public Executor shutdownAndAwaitTermination([numeric timeout='[runtime expression]'])

    Shuts down the executor in two phases, first by calling the shutdown() and rejecting all incoming tasks. Second, calling shutdownNow() aggresively if tasks did not shutdown on time to cancel any lingering tasks.

    Parameters:
    timeout - The timeout in seconds to wait for the shutdown. By deafult we use the default on the property shutdownTimeout (30s)

    shutdownNow

    public any shutdownNow()

    Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution. This method does not wait for actively executing tasks to terminate. Use awaitTermination to do that. There are no guarantees beyond best-effort attempts to stop processing actively executing tasks. This implementation cancels tasks via Thread.interrupt(), so any task that fails to respond to interrupts may never terminate.

    Returns:
    list of tasks that never commenced execution

    submit

    public cachebox.system.async.executors.FutureTask submit(any callable, [any method='run'])

    Submit a task into the executor which can return a result if any. The result of this call is a ColdBox FutureTask from which you can monitor, cancel, or get the result of the the executing task.

    Parameters:
    callable - THe callable closure/lambda/cfc to execute
    method - The default method to execute if the runnable is a CFC, defaults to `run()`
    Returns:
    A ColdBox Future Task object