Class ThreadPoolConfig.BuilderBase<BUILDER extends ThreadPoolConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends ThreadPoolConfig>

java.lang.Object
io.helidon.common.configurable.ThreadPoolConfig.BuilderBase<BUILDER,PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER,PROTOTYPE>, Prototype.ConfiguredBuilder<BUILDER,PROTOTYPE>
Direct Known Subclasses:
ThreadPoolConfig.Builder
Enclosing interface:
ThreadPoolConfig

public abstract static class ThreadPoolConfig.BuilderBase<BUILDER extends ThreadPoolConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends ThreadPoolConfig> extends Object implements Prototype.ConfiguredBuilder<BUILDER,PROTOTYPE>
Fluent API builder base for ThreadPoolSupplier.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(ThreadPoolConfig prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(ThreadPoolConfig.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • config

      public BUILDER config(Config config)
      Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.
      Specified by:
      config in interface Prototype.ConfiguredBuilder<BUILDER extends ThreadPoolConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends ThreadPoolConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • virtualThreads

      public BUILDER virtualThreads(boolean virtualThreads)
      When configured to true, an unbounded virtual executor service (project Loom) will be used.

      If enabled, all other configuration options of this executor service are ignored!

      Parameters:
      virtualThreads - whether to use virtual threads or not, defaults to false
      Returns:
      updated builder instance
      See Also:
    • corePoolSize

      public BUILDER corePoolSize(int corePoolSize)
      Core pool size of the thread pool executor. Defaults to 10.
      Parameters:
      corePoolSize - corePoolSize see ThreadPoolExecutor.getCorePoolSize()
      Returns:
      updated builder instance
      See Also:
    • maxPoolSize

      public BUILDER maxPoolSize(int maxPoolSize)
      Max pool size of the thread pool executor. Defaults to 50.
      Parameters:
      maxPoolSize - maxPoolSize see ThreadPoolExecutor.getMaximumPoolSize()
      Returns:
      updated builder instance
      See Also:
    • keepAlive

      public BUILDER keepAlive(Duration keepAlive)
      Keep alive of the thread pool executor. Defaults to "PT3M".
      Parameters:
      keepAlive - keep alive see ThreadPoolExecutor.getKeepAliveTime(java.util.concurrent.TimeUnit)
      Returns:
      updated builder instance
      See Also:
    • queueCapacity

      public BUILDER queueCapacity(int queueCapacity)
      Queue capacity of the thread pool executor. Defaults to 10000.
      Parameters:
      queueCapacity - capacity of the queue backing the executor
      Returns:
      updated builder instance
      See Also:
    • daemon

      public BUILDER daemon(boolean daemon)
      Is daemon of the thread pool executor. Defaults to true.
      Parameters:
      daemon - whether the threads are daemon threads
      Returns:
      updated builder instance
      See Also:
    • clearName

      public BUILDER clearName()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • name

      public BUILDER name(String name)
      Name of this thread pool executor.
      Parameters:
      name - the pool name
      Returns:
      updated builder instance
      See Also:
    • growthThreshold

      public BUILDER growthThreshold(int growthThreshold)
      The queue size above which pool growth will be considered if the pool is not fixed size. Defaults to 1000.
      Parameters:
      growthThreshold - the growth threshold
      Returns:
      updated builder instance
      See Also:
    • growthRate

      public BUILDER growthRate(int growthRate)
      The percentage of task submissions that should result in adding threads, expressed as a value from 1 to 100. The rate applies only when all of the following are true:
      • the pool size is below the maximum, and
      • there are no idle threads, and
      • the number of tasks in the queue exceeds the growthThreshold
      For example, a rate of 20 means that while these conditions are met one thread will be added for every 5 submitted tasks.

      Defaults to 0

      Parameters:
      growthRate - the growth rate
      Returns:
      updated builder instance
      See Also:
    • rejectionHandler

      public BUILDER rejectionHandler(ThreadPool.RejectionHandler rejectionHandler)
      Rejection policy of the thread pool executor.
      Parameters:
      rejectionHandler - the rejection handler
      Returns:
      updated builder instance
      See Also:
    • clearThreadNamePrefix

      public BUILDER clearThreadNamePrefix()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • threadNamePrefix

      public BUILDER threadNamePrefix(String threadNamePrefix)
      Name prefix for threads in this thread pool executor. Defaults to "helidon-".
      Parameters:
      threadNamePrefix - prefix of a thread name
      Returns:
      updated builder instance
      See Also:
    • shouldPrestart

      public BUILDER shouldPrestart(boolean shouldPrestart)
      Whether to prestart core threads in this thread pool executor. Defaults to true.
      Parameters:
      shouldPrestart - whether to prestart the threads
      Returns:
      updated builder instance
      See Also:
    • virtualThreads

      public boolean virtualThreads()
      When configured to true, an unbounded virtual executor service (project Loom) will be used.

      If enabled, all other configuration options of this executor service are ignored!

      Returns:
      the virtual threads
    • corePoolSize

      public int corePoolSize()
      Core pool size of the thread pool executor. Defaults to 10.
      Returns:
      the core pool size
    • maxPoolSize

      public int maxPoolSize()
      Max pool size of the thread pool executor. Defaults to 50.
      Returns:
      the max pool size
    • keepAlive

      public Duration keepAlive()
      Keep alive of the thread pool executor. Defaults to "PT3M".
      Returns:
      the keep alive
    • queueCapacity

      public int queueCapacity()
      Queue capacity of the thread pool executor. Defaults to 10000.
      Returns:
      the queue capacity
    • daemon

      public boolean daemon()
      Is daemon of the thread pool executor. Defaults to true.
      Returns:
      the daemon
    • name

      public Optional<String> name()
      Name of this thread pool executor.
      Returns:
      the name
    • growthThreshold

      public int growthThreshold()
      The queue size above which pool growth will be considered if the pool is not fixed size. Defaults to 1000.
      Returns:
      the growth threshold
    • growthRate

      public int growthRate()
      The percentage of task submissions that should result in adding threads, expressed as a value from 1 to 100. The rate applies only when all of the following are true:
      • the pool size is below the maximum, and
      • there are no idle threads, and
      • the number of tasks in the queue exceeds the growthThreshold
      For example, a rate of 20 means that while these conditions are met one thread will be added for every 5 submitted tasks.

      Defaults to 0

      Returns:
      the growth rate
    • rejectionHandler

      public ThreadPool.RejectionHandler rejectionHandler()
      Rejection policy of the thread pool executor.
      Returns:
      the rejection handler
    • threadNamePrefix

      public Optional<String> threadNamePrefix()
      Name prefix for threads in this thread pool executor. Defaults to "helidon-".
      Returns:
      the thread name prefix
    • shouldPrestart

      public boolean shouldPrestart()
      Whether to prestart core threads in this thread pool executor. Defaults to true.
      Returns:
      the should prestart
    • config

      public Optional<Config> config()
      If this instance was configured, this would be the config instance used.
      Returns:
      config node used to configure this builder, or empty if not configured
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.