Class FutureSubscriber<T>
- java.lang.Object
-
- com.oracle.coherence.concurrent.executor.subscribers.internal.FutureSubscriber<T>
-
- Type Parameters:
T- the result type
- All Implemented Interfaces:
Task.Subscriber<T>,Future<T>
- Direct Known Subclasses:
AnyFutureSubscriber,ClusteredExecutorService.CESRunnableFuture
public class FutureSubscriber<T> extends Object implements Future<T>, Task.Subscriber<T>
ATask.Subscriberthat also implementsFuture.- Since:
- 21.12
- Author:
- bo, lh
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicBooleanf_fCompletedCompleted.protected AtomicBooleanf_fErrorError.protected Task.Coordinator<T>m_coordinatorTask coordinator.protected Result<T>m_resultThe result.
-
Constructor Summary
Constructors Constructor Description FutureSubscriber()Constructs aFutureSubscriber.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel(boolean mayInterruptIfRunning)Tget()Tget(long timeout, TimeUnit unit)booleangetCompleted()Determines if theFutureSubscriberhas been completed by aTask.Coordinator.booleanhasResult()Determines if theAnyFutureSubscriberhas been completed by aTask.Coordinator.booleanisCancelled()booleanisDone()booleanisSubscribed()Determines if theFutureSubscriberhas been subscribed to aTask.Coordinator.voidonComplete()Invoked by aTask.Coordinatorwhen it is known that no additionalTask.Subscribermethod invocations will occur or has already been terminated by an error.voidonError(Throwable throwable)Invoked by aTask.Coordinatorwhen an unrecoverable error was encountered, after which no otherTask.Subscribermethods are invoked.voidonNext(T result)Invoked when aTask.Coordinatorhas produced an item for consumption.voidonSubscribe(Task.Subscription subscription)Invoked prior to theTask.SubscribermethodsTask.Subscriber.onComplete(),Task.Subscriber.onError(Throwable)andTask.Subscriber.onNext(Object)being invoked for aTask.Subscriptionto aTask.Coordinator.voidsetCoordinator(Task.Coordinator<T> coordinator)Set the coordinator.
-
-
-
Field Detail
-
m_coordinator
protected Task.Coordinator<T> m_coordinator
Task coordinator.
-
f_fCompleted
protected final AtomicBoolean f_fCompleted
Completed.
-
f_fError
protected final AtomicBoolean f_fError
Error.
-
-
Constructor Detail
-
FutureSubscriber
public FutureSubscriber()
Constructs aFutureSubscriber.
-
-
Method Detail
-
setCoordinator
public void setCoordinator(Task.Coordinator<T> coordinator)
Set the coordinator.- Parameters:
coordinator- coordinator
-
onComplete
public void onComplete()
Description copied from interface:Task.SubscriberInvoked by aTask.Coordinatorwhen it is known that no additionalTask.Subscribermethod invocations will occur or has already been terminated by an error.After this method is invoked no other
Task.Subscribermethods will be called.If this method throws an exception, the
Task.Subscriberwill be closed.- Specified by:
onCompletein interfaceTask.Subscriber<T>
-
onError
public void onError(Throwable throwable)
Description copied from interface:Task.SubscriberInvoked by aTask.Coordinatorwhen an unrecoverable error was encountered, after which no otherTask.Subscribermethods are invoked.If this method throws an exception, the
Task.Subscriberwill be closed.- Specified by:
onErrorin interfaceTask.Subscriber<T>- Parameters:
throwable- the error
-
onNext
public void onNext(T result)
Description copied from interface:Task.SubscriberInvoked when aTask.Coordinatorhas produced an item for consumption.If this method throws an exception, the
Task.Subscriberwill be closed.- Specified by:
onNextin interfaceTask.Subscriber<T>- Parameters:
result- the item (possiblynull)
-
onSubscribe
public void onSubscribe(Task.Subscription subscription)
Description copied from interface:Task.SubscriberInvoked prior to theTask.SubscribermethodsTask.Subscriber.onComplete(),Task.Subscriber.onError(Throwable)andTask.Subscriber.onNext(Object)being invoked for aTask.Subscriptionto aTask.Coordinator.- Specified by:
onSubscribein interfaceTask.Subscriber<T>- Parameters:
subscription- theTask.Subscription
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfaceFuture<T>
-
get
public T get() throws InterruptedException, ExecutionException
- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionException
-
get
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
getCompleted
public boolean getCompleted()
Determines if theFutureSubscriberhas been completed by aTask.Coordinator.- Returns:
trueif theFutureSubscriberhas been completed,falseotherwise
-
hasResult
public boolean hasResult()
Determines if theAnyFutureSubscriberhas been completed by aTask.Coordinator.- Returns:
trueif theAnyFutureSubscriberhas been completed,falseotherwise
-
isSubscribed
public boolean isSubscribed()
Determines if theFutureSubscriberhas been subscribed to aTask.Coordinator.- Returns:
trueif theFutureSubscriberhas been subscribed,falseotherwise
-
-