Class LockConfig.Builder
java.lang.Object
cloud.opencode.base.lock.LockConfig.Builder
- Enclosing class:
LockConfig
Lock Configuration Builder
锁配置构建器
Provides fluent API for building lock configurations.
提供用于构建锁配置的流式API。
- Since:
- JDK 25, opencode-base-lock V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the lock configuration 构建锁配置enableMetrics(boolean enable) Sets whether metrics collection is enabled 设置是否启用指标收集fair(boolean fair) Sets whether the lock should be fair 设置锁是否应该是公平的Sets the lock type 设置锁类型reentrant(boolean reentrant) Sets whether the lock should be reentrant 设置锁是否应该是可重入的spinCount(int spinCount) Sets the maximum spin count for spin locks 设置自旋锁的最大自旋次数Sets the default timeout for lock acquisition 设置锁获取的默认超时
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
timeout
Sets the default timeout for lock acquisition 设置锁获取的默认超时- Parameters:
timeout- the timeout duration | 超时时长- Returns:
- this builder | 此构建器
-
fair
Sets whether the lock should be fair 设置锁是否应该是公平的Fair locks grant access in FIFO order but may have lower throughput.
公平锁按FIFO顺序授予访问权限,但可能具有较低的吞吐量。
- Parameters:
fair- true for fair lock | true表示公平锁- Returns:
- this builder | 此构建器
-
reentrant
Sets whether the lock should be reentrant 设置锁是否应该是可重入的- Parameters:
reentrant- true for reentrant lock | true表示可重入锁- Returns:
- this builder | 此构建器
-
spinCount
Sets the maximum spin count for spin locks 设置自旋锁的最大自旋次数- Parameters:
spinCount- maximum spin count | 最大自旋次数- Returns:
- this builder | 此构建器
-
enableMetrics
Sets whether metrics collection is enabled 设置是否启用指标收集- Parameters:
enable- true to enable metrics | true表示启用指标- Returns:
- this builder | 此构建器
-
lockType
Sets the lock type 设置锁类型- Parameters:
type- the lock type | 锁类型- Returns:
- this builder | 此构建器
-
build
-