Package io.grpc.internal
Class ReflectionLongAdderCounter
- java.lang.Object
-
- io.grpc.internal.ReflectionLongAdderCounter
-
- All Implemented Interfaces:
LongCounter
public final class ReflectionLongAdderCounter extends java.lang.Object implements LongCounter
ALongCounter
that is implemented with a JDK8LongAdder
. Instantiates the object and invokes methods reflectively to avoid a compile time dependency on LongAdder.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.reflect.Method
addMethod
private static java.lang.reflect.Constructor<?>
defaultConstructor
private static java.lang.RuntimeException
initializationException
private java.lang.Object
instance
private static java.util.logging.Logger
logger
private static java.lang.Object[]
one
private static java.lang.reflect.Method
sumMethod
-
Constructor Summary
Constructors Constructor Description ReflectionLongAdderCounter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(long delta)
Adds the delta to this counter.(package private) static boolean
isAvailable()
Returns true if the environment supports LongAdder.long
value()
Returns the value of this counter.
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
defaultConstructor
private static final java.lang.reflect.Constructor<?> defaultConstructor
-
addMethod
private static final java.lang.reflect.Method addMethod
-
sumMethod
private static final java.lang.reflect.Method sumMethod
-
initializationException
private static final java.lang.RuntimeException initializationException
-
instance
private final java.lang.Object instance
-
one
private static final java.lang.Object[] one
-
-
Method Detail
-
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 interfaceLongCounter
-
value
public long value()
Description copied from interface:LongCounter
Returns the value of this counter.- Specified by:
value
in interfaceLongCounter
-
-