Class ReleasePermitOnComplete


  • public final class ReleasePermitOnComplete
    extends Object
    Wrapper for AsyncHandlers to release a permit on AsyncHandler.onCompleted(). This is done via a dynamic proxy to preserve all interfaces of the wrapped handler.
    • Method Detail

      • wrap

        public static <T> AsyncHandler<T> wrap​(AsyncHandler<T> handler,
                                               Semaphore available)
        Wrap handler to release the permit of the semaphore on AsyncHandler.onCompleted().
        Type Parameters:
        T - the handler result type
        Parameters:
        handler - the handler to be wrapped
        available - the Semaphore to be released when the wrapped handler is completed
        Returns:
        the wrapped handler