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
ALongCounterthat 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.MethodaddMethodprivate static java.lang.reflect.Constructor<?>defaultConstructorprivate static java.lang.RuntimeExceptioninitializationExceptionprivate java.lang.Objectinstanceprivate static java.util.logging.Loggerloggerprivate static java.lang.Object[]oneprivate static java.lang.reflect.MethodsumMethod
-
Constructor Summary
Constructors Constructor Description ReflectionLongAdderCounter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(long delta)Adds the delta to this counter.(package private) static booleanisAvailable()Returns true if the environment supports LongAdder.longvalue()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:LongCounterAdds the delta to this counter.- Specified by:
addin interfaceLongCounter
-
value
public long value()
Description copied from interface:LongCounterReturns the value of this counter.- Specified by:
valuein interfaceLongCounter
-
-