Interface ExecutorFactory

All Superinterfaces:
ExecutorBuilderFactory<ExecutorPlus,SequentialExecutorPlus>, ExecutorBuilderFactory.Jmxable<ExecutorPlus,SequentialExecutorPlus>
All Known Implementing Classes:
ExecutorFactory.Default

public interface ExecutorFactory extends ExecutorBuilderFactory.Jmxable<ExecutorPlus,SequentialExecutorPlus>
Entry point for configuring and creating new executors. Supports quick and easy construction of default-configured executors via
  • ExecutorBuilderFactory.sequential(String)
  • ExecutorBuilderFactory.pooled(String, int)
  • scheduled(String)
  • scheduled(boolean, String)
  • scheduled(boolean, String, int) Supports custom configuration of executors via
  • ExecutorBuilderFactory.configureSequential(String)
  • ExecutorBuilderFactory.configurePooled(String, int) Supports any of the above with added JMX registration via sub-factories
  • ExecutorBuilderFactory.Jmxable.withJmx(String)
  • ExecutorBuilderFactory.Jmxable.withJmxInternal() Supports any of the above with the resultant executor propagating ExecutorLocals via sub-factory
  • localAware() Supports shared executors via sub-factory localAware().withJMX() using ExecutorFactory.LocalAwareSubFactoryWithJMX.shared(String, int, ExecutorPlus.MaximumPoolSizeListener)
    • Method Details

      • localAware

        Returns:
        a factory that configures executors that propagate ExecutorLocals to the executing thread
      • scheduled

        default ScheduledExecutorPlus scheduled(String name)
        Parameters:
        name - the name of the executor, the executor's thread group, and of any worker threads
        Returns:
        a default-configured ScheduledExecutorPlus
      • scheduled

        default ScheduledExecutorPlus scheduled(String name, ExecutorFactory.SimulatorSemantics simulatorSemantics)
        Parameters:
        name - the name of the executor, the executor's thread group, and of any worker threads
        simulatorSemantics - indicate special semantics for the executor under simulation
        Returns:
        a default-configured ScheduledExecutorPlus
      • scheduled

        default ScheduledExecutorPlus scheduled(boolean executeOnShutdown, String name)
        Parameters:
        executeOnShutdown - if false, waiting tasks will be cancelled on shutdown
        name - the name of the executor, the executor's thread group, and of any worker threads
        Returns:
        a ScheduledExecutorPlus with normal thread priority
      • scheduled

        default ScheduledExecutorPlus scheduled(boolean executeOnShutdown, String name, int priority)
        Parameters:
        executeOnShutdown - if false, waiting tasks will be cancelled on shutdown
        name - the name of the executor, the executor's thread group, and of any worker threads
        priority - the thread priority of workers
        Returns:
        a ScheduledExecutorPlus
      • scheduled

        ScheduledExecutorPlus scheduled(boolean executeOnShutdown, String name, int priority, ExecutorFactory.SimulatorSemantics simulatorSemantics)
        Parameters:
        executeOnShutdown - if false, waiting tasks will be cancelled on shutdown
        name - the name of the executor, the executor's thread group, and of any worker threads
        priority - the thread priority of workers
        simulatorSemantics - indicate special semantics for the executor under simulation
        Returns:
        a ScheduledExecutorPlus
      • startThread

        Thread startThread(String name, Runnable runnable, InfiniteLoopExecutor.Daemon daemon)
        Create and start a new thread to execute runnable
        Parameters:
        name - the name of the thread
        runnable - the task to execute
        daemon - flag to indicate whether the thread should be a daemon or not
        Returns:
        the new thread
      • startThread

        default Thread startThread(String name, Runnable runnable)
        Create and start a new thread to execute runnable; this thread will be a daemon thread.
        Parameters:
        name - the name of the thread
        runnable - the task to execute
        Returns:
        the new thread
      • infiniteLoop

        Create and start a new InfiniteLoopExecutor to repeatedly invoke runnable. On shutdown, the executing thread will be interrupted; to support clean shutdown runnable should propagate InterruptedException
        Parameters:
        name - the name of the thread used to invoke the task repeatedly
        task - the task to execute repeatedly
        simulatorSafe - flag indicating if the loop thread can be intercepted / rescheduled during cluster simulation
        daemon - flag to indicate whether the loop thread should be a daemon thread or not
        interrupts - flag to indicate whether to synchronize interrupts of the task execution thread using the task's monitor this can be used to prevent interruption while performing IO operations which forbid interrupted threads. See: AbstractCommitLogSegmentManager.start()
        Returns:
        the new thread
      • infiniteLoop

        default Interruptible infiniteLoop(String name, Interruptible.SimpleTask task, InfiniteLoopExecutor.SimulatorSafe simulatorSafe)
        Create and start a new InfiniteLoopExecutor to repeatedly invoke runnable. On shutdown, the executing thread will be interrupted; to support clean shutdown runnable should propagate InterruptedException
        Parameters:
        name - the name of the thread used to invoke the task repeatedly
        task - the task to execute repeatedly
        simulatorSafe - flag indicating if the loop thread can be intercepted / rescheduled during cluster simulation
        Returns:
        the new thread
      • newThreadGroup

        ThreadGroup newThreadGroup(String name)
        Create a new thread group for use with builders - this thread group will be situated within this factory's parent thread group, and may be supplied to multiple executor builders.