Class AtomicLongGenerator

java.lang.Object
me.ahoo.cosid.jvm.AtomicLongGenerator
All Implemented Interfaces:
IdGenerator, Statistical, StringIdGenerator

public class AtomicLongGenerator extends Object implements IdGenerator
AtomicLong-based ID generator.

Generates unique IDs using an atomic counter. Thread-safe and suitable for single-JVM ID generation.

  • Field Details

    • INSTANCE

      public static final IdGenerator INSTANCE
      Shared singleton instance.
  • Constructor Details

    • AtomicLongGenerator

      public AtomicLongGenerator()
  • Method Details

    • generate

      public long generate()
      Description copied from interface: IdGenerator
      Generate a distributed ID as a long value.

      This method generates a unique numeric identifier that is guaranteed to be unique within the distributed system. The exact algorithm used depends on the implementation (e.g., Snowflake, Segment, CosId).

      Specified by:
      generate in interface IdGenerator
      Returns:
      A unique distributed ID as a long value