Class SettableIntSupplier

java.lang.Object
com.linecorp.armeria.common.util.SettableIntSupplier
All Implemented Interfaces:
IntSupplier

@UnstableApi public class SettableIntSupplier extends Object implements 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 Details

    • SettableIntSupplier

      protected SettableIntSupplier(int initialValue)
      Creates a new instance with the specified initialValue.
  • Method Details

    • of

      public static SettableIntSupplier of(int initialValue)
      Creates a new instance with the specified initialValue.
    • getAsInt

      public final int getAsInt()
      Returns the cached value.
      Specified by:
      getAsInt in interface IntSupplier
    • set

      public final void set(int value)
      Caches a value.