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>,Future<T>,org.reactivestreams.Subscriber<T>,org.reactivestreams.Subscription
public final class FutureSubscriber<T>
extends CountDownLatch
implements FlowableSubscriber<T>, Future<T>, org.reactivestreams.Subscription
A Subscriber + Future that expects exactly one upstream value and provides it
via the (blocking) Future API.
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()booleancancel(boolean mayInterruptIfRunning) get()booleanbooleanisDone()voidvoidvoidvoidonSubscribe(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) Methods inherited from class java.util.concurrent.CountDownLatch
await, await, countDown, getCount, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Field Details
-
Constructor Details
-
FutureSubscriber
public FutureSubscriber()
-
-
Method Details
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) -
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceFuture<T>
-
isDone
public boolean isDone() -
get
- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionException
-
get
public T get(long timeout, @NonNull @NonNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
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>
-
onNext
- Specified by:
onNextin interfaceorg.reactivestreams.Subscriber<T>
-
onError
- 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
-