Class Handle<T>

java.lang.Object
dev.engine.core.handle.Handle<T>
Type Parameters:
T - phantom type tag — prevents mixing handles of different resource types

public final class Handle<T> extends Object
Generational opaque handle with a phantom type parameter for compile-time safety. Supports Cleaner-based automatic resource cleanup when handles become unreachable.
  • Constructor Details

    • Handle

      public Handle(int index, int generation)
  • Method Details

    • index

      public int index()
    • generation

      public int generation()
    • registerCleanup

      public void registerCleanup(Runnable cleanupAction)
      Registers a Cleaner action that runs when this handle becomes unreachable and has not been explicitly closed. The action must NOT reference this handle.
    • markClosed

      public boolean markClosed()
      Marks this handle as explicitly closed. Prevents the Cleaner from running the cleanup action. Returns true if this call actually closed it (false if already closed).
    • isClosed

      public boolean isClosed()
    • invalid

      public static <T> Handle<T> invalid()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object