Package org.aksw.commons.util.ref
Class RefFutureImpl<T>
- java.lang.Object
-
- org.aksw.commons.util.ref.RefDelegateBase<CompletableFuture<T>,Ref<CompletableFuture<T>>>
-
- org.aksw.commons.util.ref.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>
-
-
Field Summary
-
Fields inherited from class org.aksw.commons.util.ref.RefDelegateBase
delegate
-
-
Constructor Summary
Constructors Constructor Description RefFutureImpl(Ref<CompletableFuture<T>> delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RefFuture<T>acquire()static voidcancelFutureOrCloseRef(CompletableFuture<? extends Ref<?>> future)static <T> voidcancelFutureOrCloseValue(CompletableFuture<T> future, java.util.function.Consumer<? super T> valueCloseAction)Registers a whenComplete action that closes the value if loaded.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 sstatic <T> RefFuture<T>fromRef(Ref<T> ref)Wrap an existing ref with completed futurestatic <T> RefFuture<T>wrap(Ref<CompletableFuture<T>> delegate)A simple wrapping of an instance ofRef<CompletableFuture<T>>as a more handy instance ofRefFuture<T>.static <T> RefFuture<T>wrap2(Ref<? extends CompletableFuture<Ref<T>>> delegate)Wrap a Ref> as a RefFuture . static <T> RefFuture<T>wrap3(Ref<? extends Ref<? extends CompletableFuture<T>>> delegate)-
Methods inherited from class org.aksw.commons.util.ref.RefDelegateBase
getDelegate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.aksw.commons.util.ref.Ref
acquireMapped
-
Methods inherited from interface org.aksw.commons.util.ref.RefDelegate
acquire, close, get, getAcquisitionStackTrace, getCloseStackTrace, getCloseTriggerStackTrace, getDelegate, getRootRef, getSynchronizer, isAlive, isClosed
-
Methods inherited from interface org.aksw.commons.util.ref.RefFuture
acquireTransformed, acquireTransformedAndCloseThis, await
-
-
-
-
Constructor Detail
-
RefFutureImpl
public RefFutureImpl(Ref<CompletableFuture<T>> delegate)
-
-
Method Detail
-
wrap
public static <T> RefFuture<T> wrap(Ref<CompletableFuture<T>> delegate)
A simple wrapping of an instance ofRef<CompletableFuture<T>>as a more handy instance ofRefFuture<T>. All methods of the returned RefFuture delegate to the original Ref. Note, thatRefFuture<T>is a sub-interface ofRef<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, java.util.function.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> 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)
-
-