Enum Class WaitPolicy
- All Implemented Interfaces:
Serializable, Comparable<WaitPolicy>, Constable
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic WaitPolicyReturns the enum constant of this class with the specified name.static WaitPolicy[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
BLOCK
Block and wait for an object to become available. 阻塞并等待对象可用。 -
FAIL
Fail immediately with an exception. 立即抛出异常失败。 -
GROW
Grow the pool beyond maxTotal (use with caution). 增长池超过maxTotal(谨慎使用)。
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-