Interface AvailabilityProvider

    • Method Detail

      • getAvailableFuture

        CompletableFuture<?> getAvailableFuture()
        Returns:
        a future that is completed if the respective provider is available.
      • isAvailable

        default boolean isAvailable()
        In order to best-effort avoid volatile access in CompletableFuture.isDone(), we check the condition of future == AVAILABLE firstly for getting probable performance benefits while hot looping.

        It is always safe to use this method in performance nonsensitive scenarios to get the precise state.

        Returns:
        true if this instance is available for further processing.
      • isApproximatelyAvailable

        default boolean isApproximatelyAvailable()
        Checks whether this instance is available only via constant AVAILABLE to avoid performance concern caused by volatile access in CompletableFuture.isDone(). So it is mainly used in the performance sensitive scenarios which do not always need the precise state.

        This method is still safe to get the precise state if getAvailableFuture() was touched via (.get(), .wait(), .isDone(), ...) before, which also has a "happen-before" relationship with this call.

        Returns:
        true if this instance is available for further processing.