Enum Class WaitPolicy

java.lang.Object
java.lang.Enum<WaitPolicy>
cloud.opencode.base.pool.policy.WaitPolicy
All Implemented Interfaces:
Serializable, Comparable<WaitPolicy>, Constable

public enum WaitPolicy extends Enum<WaitPolicy>
WaitPolicy - Wait Policy Enumeration WaitPolicy - 等待策略枚举

Defines how the pool behaves when exhausted and a borrow is requested.

定义池耗尽时请求借用的行为。

Policies | 策略:

  • BLOCK - Wait for available object - 等待可用对象
  • FAIL - Throw exception immediately - 立即抛出异常
  • GROW - Create new object beyond max - 创建超出最大值的新对象

Features | 主要功能:

  • Three exhaustion strategies: BLOCK, FAIL, GROW - 三种耗尽策略: 阻塞、失败、增长
  • Immutable enum constants for thread-safe configuration - 不可变枚举常量,线程安全配置
  • Integrates with PoolConfig for flexible pool behavior - 与PoolConfig集成实现灵活的池行为

Usage Examples | 使用示例:

PoolConfig config = PoolConfig.builder()
    .waitPolicy(WaitPolicy.BLOCK)
    .maxWait(Duration.ofSeconds(5))
    .build();

Security | 安全性:

  • Thread-safe: Yes (enum is immutable) - 线程安全: 是(枚举不可变)
Since:
JDK 25, opencode-base-pool V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Enum Constant Details

    • BLOCK

      public static final WaitPolicy BLOCK
      Block and wait for an object to become available. 阻塞并等待对象可用。
    • FAIL

      public static final WaitPolicy FAIL
      Fail immediately with an exception. 立即抛出异常失败。
    • GROW

      public static final WaitPolicy GROW
      Grow the pool beyond maxTotal (use with caution). 增长池超过maxTotal(谨慎使用)。
  • Method Details

    • values

      public static WaitPolicy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static WaitPolicy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null