Class SecretGenerator.VarHandleGenerator

  • Enclosing class:
    SecretGenerator

    public static final class SecretGenerator.VarHandleGenerator
    extends Generator
    This class let's PerfMark have fairly low overhead detection if it is enabled, with reasonable time between enabled and other threads noticing. Since this uses Java 9 APIs, it may not be available.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long gen  
      private static java.lang.invoke.VarHandle GEN  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long costOfGetNanos()
      Returns the approximate cost to read the generation.
      long costOfSetNanos()
      Returns the approximate cost to change the generation.
      long getGeneration()
      Gets the current generation, shifted left by Generator.GEN_OFFSET.
      void setGeneration​(long generation)
      Sets the current generation count.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • GEN

        private static final java.lang.invoke.VarHandle GEN
      • gen

        private long gen
    • Constructor Detail

      • VarHandleGenerator

        public VarHandleGenerator()
    • Method Detail

      • setGeneration

        public void setGeneration​(long generation)
        Description copied from class: Generator
        Sets the current generation count. This should be eventually noticeable for callers of Generator.getGeneration(). An odd number means the library is enabled, while an even number means the library is disabled.
        Overrides:
        setGeneration in class Generator
        Parameters:
        generation - the generation id, shifted left by Generator.GEN_OFFSET.
      • getGeneration

        public long getGeneration()
        Description copied from class: Generator
        Gets the current generation, shifted left by Generator.GEN_OFFSET. An odd number means the library is enabled, while an even number means the library is disabled.
        Overrides:
        getGeneration in class Generator
        Returns:
        the current generation or Generator.FAILURE.
      • costOfSetNanos

        public long costOfSetNanos()
        Description copied from class: Generator
        Returns the approximate cost to change the generation.
        Overrides:
        costOfSetNanos in class Generator
        Returns:
        an approximate number of nanoseconds needed to change the generator value.
      • costOfGetNanos

        public long costOfGetNanos()
        Description copied from class: Generator
        Returns the approximate cost to read the generation.
        Overrides:
        costOfGetNanos in class Generator
        Returns:
        an approximate number of nanoseconds needed to read the generator value.