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
Generational opaque handle with a phantom type parameter for compile-time safety.
Supports Cleaner-based automatic resource cleanup when handles become unreachable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanintinthashCode()intindex()static <T> Handle<T> invalid()booleanisClosed()booleanMarks this handle as explicitly closed.voidregisterCleanup(Runnable cleanupAction) Registers a Cleaner action that runs when this handle becomes unreachable and has not been explicitly closed.toString()
-
Constructor Details
-
Handle
public Handle(int index, int generation)
-
-
Method Details
-
index
public int index() -
generation
public int generation() -
registerCleanup
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
-
equals
-
hashCode
-
toString
-