Package com.linecorp.armeria.common.util
Class SettableIntSupplier
java.lang.Object
com.linecorp.armeria.common.util.SettableIntSupplier
- All Implemented Interfaces:
IntSupplier
Supplies a cached value which can be useful for the below case.
- Supplies the maximum number of concurrent active requests dynamically for ConcurrencyLimit
.
For example:
class DynamicSupplier extends SettableIntSupplier {
DynamicSupplier() {
super(10); //set initial value
AnyListener<Integer> listener = ...
listener.addListener(this::set);
}
}
-
Constructor Summary
ModifierConstructorDescriptionprotected
SettableIntSupplier
(int initialValue) Creates a new instance with the specifiedinitialValue
. -
Method Summary
Modifier and TypeMethodDescriptionfinal int
getAsInt()
Returns the cached value.static SettableIntSupplier
of
(int initialValue) Creates a new instance with the specifiedinitialValue
.final void
set
(int value) Caches a value.
-
Constructor Details
-
SettableIntSupplier
protected SettableIntSupplier(int initialValue) Creates a new instance with the specifiedinitialValue
.
-
-
Method Details
-
of
Creates a new instance with the specifiedinitialValue
. -
getAsInt
public final int getAsInt()Returns the cached value.- Specified by:
getAsInt
in interfaceIntSupplier
-
set
public final void set(int value) Caches a value.
-