Module lettuce.core

Interface EventLoopGroupProvider

All Known Implementing Classes:
DefaultEventLoopGroupProvider

public interface EventLoopGroupProvider
Provider for EventLoopGroups and EventExecutorGroups. A event loop group is a heavy-weight instance holding and providing Thread instances. Multiple instances can be created but are expensive. Keeping too many instances open can exhaust the number of open files.

Usually, the default settings are sufficient. However, customizing might be useful for some special cases where multiple RedisClient or RedisClusterClient instances are needed that share one or more event loop groups.

The EventLoopGroupProvider allows to allocate and release instances implementing EventExecutorGroup. The EventExecutorGroup instances must not be terminated or shutdown by the user. Resources are managed by the particular EventLoopGroupProvider.

You can implement your own EventLoopGroupProvider to share existing EventLoopGroup's with lettuce.
Since:
3.4
Author:
Mark Paluch
  • Method Details

    • allocate

      <T extends EventLoopGroup> T allocate​(Class<T> type)
      Retrieve a EventLoopGroup for the channel type. Do not terminate or shutdown the instance. Call the release(EventExecutorGroup, long, long, TimeUnit) to release an individual instance or shutdown(long, long, TimeUnit) method to free the all resources.
      Type Parameters:
      T - type of the EventLoopGroup
      Parameters:
      type - class of the EventLoopGroup, must not be null
      Returns:
      the EventLoopGroup.
    • threadPoolSize

      int threadPoolSize()
      Returns the pool size (number of threads) for IO threads. The indicated size does not reflect the number for all IO threads, it is the number of threads that are used to create a particular thread pool.
      Returns:
      the pool size (number of threads) for all IO tasks.
    • release

      Future<Boolean> release​(EventExecutorGroup eventLoopGroup, long quietPeriod, long timeout, TimeUnit unit)
      Release a eventLoopGroup instance. The method will shutdown/terminate the EventExecutorGroup if it is no longer needed.
      Parameters:
      eventLoopGroup - the eventLoopGroup instance, must not be null
      quietPeriod - the quiet period
      timeout - the timeout
      unit - time unit for the quiet period/the timeout
      Returns:
      a close future to synchronize the called for shutting down.
    • shutdown

      Future<Boolean> shutdown​(long quietPeriod, long timeout, TimeUnit timeUnit)
      Shutdown the provider and release all instances.
      Parameters:
      quietPeriod - the quiet period
      timeout - the timeout
      timeUnit - the unit of quietPeriod and timeout
      Returns:
      a close future to synchronize the called for shutting down.