Package io.perfmark.impl
Class Generator
- java.lang.Object
-
- io.perfmark.impl.Generator
-
@NotThreadSafe public abstract class Generator extends java.lang.ObjectA Generator keeps track of what generation the PerfMark library is on. A generation is a way to group PerfMark recorded tasks and links together. This allows dynamically enabling and disabling PerfMark. Each time the library is enabled, a new generation is started and associated with all the recorded data.Normal users are not expected to use this class.
-
-
Field Summary
Fields Modifier and Type Field Description static longFAILURERepresents a failure to enable PerfMark library.static intGEN_OFFSETThe number of reserved bits at the bottom of the generation.
-
Constructor Summary
Constructors Modifier Constructor Description protectedGenerator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description longcostOfGetNanos()Returns the approximate cost to read the generation.longcostOfSetNanos()Returns the approximate cost to change the generation.abstract longgetGeneration()Gets the current generation, shifted left byGEN_OFFSET.abstract voidsetGeneration(long generation)Sets the current generation count.
-
-
-
Field Detail
-
GEN_OFFSET
public static final int GEN_OFFSET
The number of reserved bits at the bottom of the generation. All generations should be left-shifted by this amount.- See Also:
- Constant Field Values
-
FAILURE
public static final long FAILURE
Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a previous failure to set the generation. It can also be used to indicate the generation count has overflowed.- See Also:
- Constant Field Values
-
-
Method Detail
-
setGeneration
public abstract void setGeneration(long generation)
Sets the current generation count. This should be eventually noticeable for callers ofgetGeneration(). An odd number means the library is enabled, while an even number means the library is disabled.- Parameters:
generation- the generation id, shifted left byGEN_OFFSET.
-
getGeneration
public abstract long getGeneration()
Gets the current generation, shifted left byGEN_OFFSET. An odd number means the library is enabled, while an even number means the library is disabled.- Returns:
- the current generation or
FAILURE.
-
costOfSetNanos
public long costOfSetNanos()
Returns the approximate cost to change the generation.- Returns:
- an approximate number of nanoseconds needed to change the generator value.
-
costOfGetNanos
public long costOfGetNanos()
Returns the approximate cost to read the generation.- Returns:
- an approximate number of nanoseconds needed to read the generator value.
-
-