Class RefFutureImpl<T>

All Implemented Interfaces:
AutoCloseable, Ref<CompletableFuture<T>>, RefDelegate<CompletableFuture<T>,Ref<CompletableFuture<T>>>, RefFuture<T>

public class RefFutureImpl<T> extends RefDelegateBase<CompletableFuture<T>,Ref<CompletableFuture<T>>> implements RefFuture<T>
  • Constructor Details

  • Method Details

    • acquire

      public RefFuture<T> acquire()
      Specified by:
      acquire in interface Ref<T>
      Specified by:
      acquire in interface RefFuture<T>
    • wrap

      public static <T> RefFuture<T> wrap(Ref<CompletableFuture<T>> delegate)
      A simple wrapping of an instance of Ref<CompletableFuture<T>> as a more handy instance of RefFuture<T>. All methods of the returned RefFuture delegate to the original Ref. Note, that RefFuture<T> is a sub-interface of Ref<CompletableFuture<T>>.
      Type Parameters:
      T -
      Parameters:
      delegate -
      Returns:
    • fromRef

      public static <T> RefFuture<T> fromRef(Ref<T> ref)
      Wrap an existing ref with completed future
    • fromFuture

      public static <T> RefFuture<T> fromFuture(CompletableFuture<Ref<T>> future, Object synchronizer)
      Create a ref that upon close cancels the future or closes the ref when it is available s
    • cancelFutureOrCloseRef

      public static void cancelFutureOrCloseRef(CompletableFuture<? extends Ref<?>> future)
    • cancelFutureOrCloseValue

      public static <T> void cancelFutureOrCloseValue(CompletableFuture<T> future, Consumer<? super T> valueCloseAction)
      Registers a whenComplete action that closes the value if loaded. Then immediately attempts to cancel the future.
    • wrap2

      public static <T> RefFuture<T> wrap2(Ref<? extends CompletableFuture<Ref<T>>> delegate)
      Wrap a Ref<RefFuture> as a RefFuture. This creates a new Ref that closes the delegate on close. This method does not acquire the delegate, so after wrapping the delegate should be considered as 'owned' by this wrapper; the delegate should no longer be closed directly.
    • wrap3

      public static <T> RefFuture<T> wrap3(Ref<? extends Ref<? extends CompletableFuture<T>>> delegate)