Class ActivationToken

java.lang.Object
io.kroxylicious.proxy.internal.util.ActivationToken

public class ActivationToken extends Object
A thread-safe state that ensures exactly-once increment and decrement operations.

This counter prevents race conditions in connection lifecycle management by tracking its own state and only allowing state transitions: INITIAL → ACTIVE → INACTIVE. Multiple calls to increment/decrement methods are safe and idempotent.

Thread Safety: This class is thread-safe and can be used concurrently from multiple threads.

  • Constructor Details

    • ActivationToken

      public ActivationToken(AtomicInteger currentCounter)
  • Method Details

    • acquire

      public void acquire()
      Attempts to increment the counter if it is in the INITIAL state. If the state is already ACQUIRED or RELEASED, this method has no effect.
    • release

      public void release()