Package glide.internal
Class AsyncRegistry
- java.lang.Object
-
- glide.internal.AsyncRegistry
-
public final class AsyncRegistry extends java.lang.ObjectAsync registry for correlating native callbacks with JavaCompletableFutures.Responsibilities:
- Maintain a thread-safe mapping from correlation id to the original future
- Enforce per-client max inflight requests in Java (0 = defer to core default)
- Perform atomic cleanup on completion to avoid races and leaks
- Provide batched completion helpers to reduce native call overhead
Timeouts, backpressure defaults, and concurrency tuning are handled by the Rust core.
-
-
Constructor Summary
Constructors Constructor Description AsyncRegistry()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcleanupClient(long clientHandle)Clean up per-client tracking when a client is closedstatic booleancompleteCallback(long correlationId, java.lang.Object result)Complete callback with proper race condition handling.static booleancompleteCallbackWithErrorCode(long correlationId, int errorTypeCode, java.lang.String errorMessage)Complete with error using a structured error code from native layer.static intgetPendingCount()Get current pending operation countstatic <T> longregister(java.util.concurrent.CompletableFuture<T> future, int maxInflightRequests, long clientHandle)Register future with client-specific inflight limit and client handle for per-client trackingstatic voidremoveShutdownHook()Remove the automatic shutdown hook, allowing users to manage shutdown manually.static voidreset()Reset all internal state.static voidshutdown()Shutdown cleanup - cancel all pending operations during client shutdown
-
-
-
Method Detail
-
register
public static <T> long register(java.util.concurrent.CompletableFuture<T> future, int maxInflightRequests, long clientHandle)Register future with client-specific inflight limit and client handle for per-client tracking
-
completeCallback
public static boolean completeCallback(long correlationId, java.lang.Object result)Complete callback with proper race condition handling. Supports both regular Java objects and DirectByteBuffer for large responses (>16KB).
-
completeCallbackWithErrorCode
public static boolean completeCallbackWithErrorCode(long correlationId, int errorTypeCode, java.lang.String errorMessage)Complete with error using a structured error code from native layer. Codes map to glide-core RequestErrorType: 0-Unspecified, 1-ExecAbort, 2-Timeout, 3-Disconnect.
-
getPendingCount
public static int getPendingCount()
Get current pending operation count
-
shutdown
public static void shutdown()
Shutdown cleanup - cancel all pending operations during client shutdown
-
cleanupClient
public static void cleanupClient(long clientHandle)
Clean up per-client tracking when a client is closed
-
reset
public static void reset()
Reset all internal state. Intended for test isolation and client shutdown cleanup.
-
removeShutdownHook
public static void removeShutdownHook()
Remove the automatic shutdown hook, allowing users to manage shutdown manually. Call this if you want to control shutdown behavior yourself.
-
-