Class ReflectionLongAdderCounter

java.lang.Object
io.grpc.internal.ReflectionLongAdderCounter
All Implemented Interfaces:
LongCounter

public final class ReflectionLongAdderCounter extends Object implements LongCounter
A LongCounter that is implemented with a JDK8
invalid reference
LongAdder
. Instantiates the object and invokes methods reflectively to avoid a compile time dependency on LongAdder.
  • Field Details

    • logger

      private static final Logger logger
    • defaultConstructor

      private static final Constructor<?> defaultConstructor
    • addMethod

      private static final Method addMethod
    • sumMethod

      private static final Method sumMethod
    • initializationException

      private static final RuntimeException initializationException
    • instance

      private final Object instance
    • one

      private static final Object[] one
  • Constructor Details

    • ReflectionLongAdderCounter

      ReflectionLongAdderCounter()
  • Method Details

    • isAvailable

      static boolean isAvailable()
      Returns true if the environment supports LongAdder. In other words, we are running in >= JDK8.
    • add

      public void add(long delta)
      Description copied from interface: LongCounter
      Adds the delta to this counter.
      Specified by:
      add in interface LongCounter
    • value

      public long value()
      Description copied from interface: LongCounter
      Returns the value of this counter.
      Specified by:
      value in interface LongCounter