Class OrderedThreadPoolExecutor

All Implemented Interfaces:
Executor, ExecutorService

public class OrderedThreadPoolExecutor extends ThreadPoolExecutor
A ThreadPoolExecutor that maintains the order of IoEvents.

If you don't need to maintain the order of events per session, please use UnorderedThreadPoolExecutor.

  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
      A logger for this class (commented as it breaks MDCFlter tests)
    • DEFAULT_INITIAL_THREAD_POOL_SIZE

      private static final int DEFAULT_INITIAL_THREAD_POOL_SIZE
      A default value for the initial pool size
      See Also:
    • DEFAULT_MAX_THREAD_POOL

      private static final int DEFAULT_MAX_THREAD_POOL
      A default value for the maximum pool size
      See Also:
    • DEFAULT_KEEP_ALIVE

      private static final int DEFAULT_KEEP_ALIVE
      A default value for the KeepAlive delay
      See Also:
    • EXIT_SIGNAL

      private static final IoSession EXIT_SIGNAL
    • TASKS_QUEUE

      private static final AttributeKey TASKS_QUEUE
      A key stored into the session's attribute for the event tasks being queued
    • waitingSessions

      private final BlockingQueue<IoSession> waitingSessions
      A queue used to store the available sessions
    • workers

      private final Set<OrderedThreadPoolExecutor.Worker> workers
    • largestPoolSize

      private volatile int largestPoolSize
    • idleWorkers

      private final AtomicInteger idleWorkers
    • completedTaskCount

      private long completedTaskCount
    • shutdown

      private volatile boolean shutdown
    • eventQueueHandler

      private final IoEventQueueHandler eventQueueHandler
  • Constructor Details

    • OrderedThreadPoolExecutor

      public OrderedThreadPoolExecutor()
      Creates a default ThreadPool, with default values : - minimum pool size is 0 - maximum pool size is 16 - keepAlive set to 30 seconds - A default ThreadFactory - All events are accepted
    • OrderedThreadPoolExecutor

      public OrderedThreadPoolExecutor(int maximumPoolSize)
      Creates a default ThreadPool, with default values : - minimum pool size is 0 - keepAlive set to 30 seconds - A default ThreadFactory - All events are accepted
      Parameters:
      maximumPoolSize - The maximum pool size
    • OrderedThreadPoolExecutor

      public OrderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize)
      Creates a default ThreadPool, with default values : - keepAlive set to 30 seconds - A default ThreadFactory - All events are accepted
      Parameters:
      corePoolSize - The initial pool sizePoolSize
      maximumPoolSize - The maximum pool size
    • OrderedThreadPoolExecutor

      public OrderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit)
      Creates a default ThreadPool, with default values : - A default ThreadFactory - All events are accepted
      Parameters:
      corePoolSize - The initial pool sizePoolSize
      maximumPoolSize - The maximum pool size
      keepAliveTime - Default duration for a thread
      unit - Time unit used for the keepAlive value
    • OrderedThreadPoolExecutor

      public OrderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, IoEventQueueHandler eventQueueHandler)
      Creates a default ThreadPool, with default values : - A default ThreadFactory
      Parameters:
      corePoolSize - The initial pool sizePoolSize
      maximumPoolSize - The maximum pool size
      keepAliveTime - Default duration for a thread
      unit - Time unit used for the keepAlive value
      eventQueueHandler - The queue used to store events
    • OrderedThreadPoolExecutor

      public OrderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory)
      Creates a default ThreadPool, with default values : - A default ThreadFactory
      Parameters:
      corePoolSize - The initial pool sizePoolSize
      maximumPoolSize - The maximum pool size
      keepAliveTime - Default duration for a thread
      unit - Time unit used for the keepAlive value
      threadFactory - The factory used to create threads
    • OrderedThreadPoolExecutor

      public OrderedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory, IoEventQueueHandler eventQueueHandler)
      Creates a new instance of a OrderedThreadPoolExecutor.
      Parameters:
      corePoolSize - The initial pool sizePoolSize
      maximumPoolSize - The maximum pool size
      keepAliveTime - Default duration for a thread
      unit - Time unit used for the keepAlive value
      threadFactory - The factory used to create threads
      eventQueueHandler - The queue used to store events
  • Method Details