Class FutureSubscriber<T>
- java.lang.Object
-
- java.util.concurrent.CountDownLatch
-
- io.reactivex.rxjava3.internal.subscribers.FutureSubscriber<T>
-
- Type Parameters:
T- the value type
- All Implemented Interfaces:
FlowableSubscriber<T>,java.util.concurrent.Future<T>,org.reactivestreams.Subscriber<T>,org.reactivestreams.Subscription
public final class FutureSubscriber<T> extends java.util.concurrent.CountDownLatch implements FlowableSubscriber<T>, java.util.concurrent.Future<T>, org.reactivestreams.Subscription
A Subscriber + Future that expects exactly one upstream value and provides it via the (blocking) Future API.
-
-
Constructor Summary
Constructors Constructor Description FutureSubscriber()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()booleancancel(boolean mayInterruptIfRunning)Tget()Tget(long timeout, @NonNull java.util.concurrent.TimeUnit unit)booleanisCancelled()booleanisDone()voidonComplete()voidonError(java.lang.Throwable t)voidonNext(T t)voidonSubscribe(org.reactivestreams.Subscription s)Implementors of this method should make sure everything that needs to be visible inSubscriber.onNext(Object)is established before callingSubscription.request(long).voidrequest(long n)
-
-
-
Field Detail
-
value
T value
-
error
java.lang.Throwable error
-
upstream
final java.util.concurrent.atomic.AtomicReference<org.reactivestreams.Subscription> upstream
-
-
Method Detail
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancelin interfacejava.util.concurrent.Future<T>
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfacejava.util.concurrent.Future<T>
-
isDone
public boolean isDone()
- Specified by:
isDonein interfacejava.util.concurrent.Future<T>
-
get
public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
getin interfacejava.util.concurrent.Future<T>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
get
public T get(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
getin interfacejava.util.concurrent.Future<T>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutException
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription s)
Description copied from interface:FlowableSubscriberImplementors of this method should make sure everything that needs to be visible inSubscriber.onNext(Object)is established before callingSubscription.request(long). In practice this means no initialization should happen after therequest()call and additional behavior is thread safe in respect toonNext.- Specified by:
onSubscribein interfaceFlowableSubscriber<T>- Specified by:
onSubscribein interfaceorg.reactivestreams.Subscriber<T>
-
onError
public void onError(java.lang.Throwable t)
- Specified by:
onErrorin interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public void onComplete()
- Specified by:
onCompletein interfaceorg.reactivestreams.Subscriber<T>
-
cancel
public void cancel()
- Specified by:
cancelin interfaceorg.reactivestreams.Subscription
-
request
public void request(long n)
- Specified by:
requestin interfaceorg.reactivestreams.Subscription
-
-