Interface Task.Coordinator<T>
- Type Parameters:
T
- the type of the collected results
Task
results that additionally permits
coordination of the submitted Task
.
Results collected by the execution of a Task
using one or more
Executor
s are sent to registered Task.Subscriber
s. Each registered
Task.Subscriber
receives the same results (via method
Task.Subscriber.onNext(Object)
) in the same order, unless drops or
errors are encountered.
If a Task.Coordinator
encounters an error that does not allow results to be
issued to a Task.Subscriber
, the Task.Subscriber.onError(Throwable)
is
called, and then receives no further results. Otherwise, when it is known that
no further results will be issued to it, the Task.Subscriber.onComplete()
is called.
Task.Coordinator
s ensure that Task.Subscriber
method invocations for
each subscription are strictly ordered in happens-before order.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel
(boolean mayInterruptIfRunning) Attempts to cancel execution of theTask
.Obtain the properties of theTask
being coordinated.Obtains the unique identity of theTask
being coordinated.boolean
Returnstrue
if theTask
was cancelled before it completed normally.boolean
isDone()
Returnstrue
if theTask
completed.void
subscribe
(Task.Subscriber<? super T> subscriber) Subscribes the specifiedTask.Subscriber
to theTask.Coordinator
of aTask
to receive collected results.
-
Method Details
-
subscribe
Subscribes the specifiedTask.Subscriber
to theTask.Coordinator
of aTask
to receive collected results.If already subscribed, or the attempt to subscribe fails, the
Task.Subscriber.onError(Throwable)
method is invoked with anIllegalStateException
.- Parameters:
subscriber
- theTask.Subscriber
-
cancel
boolean cancel(boolean mayInterruptIfRunning) Attempts to cancel execution of theTask
. This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some other reason. If successful, and this task has not started when cancel is called, this task should never run. If the task has already started, then the mayInterruptIfRunning parameter determines whether the thread executing this task should be interrupted in an attempt to stop the task.After this method returns, subsequent calls to isDone() will always return true. Subsequent calls to isDone() will always return true if this method returned true.
- Parameters:
mayInterruptIfRunning
-true
if the thread executing this task should be interrupted; otherwise, in-progress tasks are allowed to complete- Returns:
false
if the task could not be cancelled, typically because it has already completed normally;true
otherwise- See Also:
-
isCancelled
boolean isCancelled()Returnstrue
if theTask
was cancelled before it completed normally.- Returns:
true
if this task was cancelled before it completed- See Also:
-
isDone
boolean isDone()Returnstrue
if theTask
completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will returntrue
.- Returns:
true
if this task completed- See Also:
-
getTaskId
String getTaskId()Obtains the unique identity of theTask
being coordinated.- Returns:
- the task identity
-
getProperties
Task.Properties getProperties()Obtain the properties of theTask
being coordinated.- Returns:
- the task properties
-