public static final class PessimisticLockFactory.BackoffParameters extends Object
acquireAttempts
This used to specify the maxium number of attempts to obtain a lock before we back off
(throwing a LockAcquisitionFailedException if it does). A value of '-1' means unlimited attempts.
maximumQueued
Maximum number of queued threads we allow to try and obtain a lock, if another thread tries to obtain the lock
after the limit is reached we back off (throwing a LockAcquisitionFailedException). A value of '-1'
means the maximum queued threads is unbound / no limit.
NOTE: This relies on approximation given by ReentrantLock.getQueueLength() so the effective limit may
be higher then specified. Since this is a back off control this should be ok.
lockAttemptTimeout Time permitted to try and obtain a lock per acquire attempt in milliseconds. NOTE: The lockAttemptTimeout of the first attempt is always zero, so max wait time is approximately (acquireAttempts - 1) * lockAttemptTimeout
| Modifier and Type | Field and Description |
|---|---|
int |
acquireAttempts |
int |
lockAttemptTimeout |
int |
maximumQueued |
| Constructor and Description |
|---|
BackoffParameters(int acquireAttempts,
int maximumQueued,
int lockAttemptTimeout)
Initialize the BackoffParameters using given parameters.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasAcquireAttemptLimit() |
boolean |
hasAcquireQueueLimit() |
boolean |
maximumQueuedThreadsReached(int queueLength) |
public final int acquireAttempts
public final int maximumQueued
public final int lockAttemptTimeout
public BackoffParameters(int acquireAttempts,
int maximumQueued,
int lockAttemptTimeout)
acquireAttempts - the total number of attempts to make to acquire the lock. A value of -1 means indefinite attemptsmaximumQueued - the threshold of the number of threads queued for acquiring the lock, or -1 to ignore queue sizelockAttemptTimeout - the amount of time to wait, in milliseconds, for each lock acquisition attemptCopyright © 2010–2018. All rights reserved.