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 TypeMethodDescriptionvoid
cancel()
boolean
cancel
(boolean mayInterruptIfRunning) get()
boolean
boolean
isDone()
void
void
void
void
onSubscribe
(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)
.void
request
(long n) Methods inherited from class java.util.concurrent.CountDownLatch
await, await, countDown, getCount, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:
isCancelled
in interfaceFuture<T>
-
isDone
public boolean isDone() -
get
- Specified by:
get
in interfaceFuture<T>
- Throws:
InterruptedException
ExecutionException
-
get
public T get(long timeout, @NonNull @NonNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
get
in interfaceFuture<T>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription s) Description copied from interface:FlowableSubscriber
Implementors 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:
onSubscribe
in interfaceFlowableSubscriber<T>
- Specified by:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<T>
-
onNext
- Specified by:
onNext
in interfaceorg.reactivestreams.Subscriber<T>
-
onError
- Specified by:
onError
in interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public void onComplete()- Specified by:
onComplete
in interfaceorg.reactivestreams.Subscriber<T>
-
cancel
public void cancel()- Specified by:
cancel
in interfaceorg.reactivestreams.Subscription
-
request
public void request(long n) - Specified by:
request
in interfaceorg.reactivestreams.Subscription
-