Class AbstractTaskCoordinator<T>

    • Method Detail

      • cancel

        public boolean cancel​(boolean mayInterruptIfRunning)
        Description copied from interface: Task.Coordinator
        Attempts to cancel execution of the Task. 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.

        Based on https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Future.html#cancel(boolean)
        Specified by:
        cancel in interface Task.Coordinator<T>
        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
      • isCancelled

        public boolean isCancelled()
        Description copied from interface: Task.Coordinator
        Returns true if the Task was cancelled before it completed normally.

        Based on https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Future.html#isCancelled()

        Specified by:
        isCancelled in interface Task.Coordinator<T>
        Returns:
        true if this task was cancelled before it completed
      • isDone

        public boolean isDone()
        Description copied from interface: Task.Coordinator
        Returns true if the Task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.

        Based on https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Future.html#isDone()

        Specified by:
        isDone in interface Task.Coordinator<T>
        Returns:
        true if this task completed
      • offer

        public void offer​(Result<T> item)
        Offers an item to be asynchronously published to current Task.Subscribers.
        Parameters:
        item - the item
      • subscribeRetainedTask

        protected abstract void subscribeRetainedTask​(Task.Subscriber<?> subscriber)
        Subscribes to a retained task (a task that has completed execution, but it still held in memory).
        Parameters:
        subscriber - the subscriber
        Throws:
        IllegalStateException - if there is no task to subscribe to