Package 

Class Task

  • All Implemented Interfaces:
    java.lang.Comparable , java.util.concurrent.Callable

    
    public abstract class Task<Result>
     implements Callable<QueueResult>, Comparable<Task<out Object>>
                        

    Executable piece of work in the Queue, child classes can do any actual type of work, Queue doesn't care. This class defines core principles, like dependencies, priority, retry policy, id, etc.

    • Constructor Detail

      • Task

        Task(TaskType type, Array<TaskType> dependencies, String id)
        Constructs new task, this constructor allows the most customisationsPay attention to the id parameter, it's used to restrict parallel execution of tasks of the same type.That means if two tasks of equal type have equal id - they considered equal.Queue behaves like a set, so equal tasks cannot be added to the queue at the same time.
        Parameters:
        type - Type of the task, used to calculate dependencies and priority
        dependencies - types of tasks, which this task should wait for being executed before it
        id - unique identifier of the task, allows to distinguish it from othersIf null is passed - each task as unique, order is used.
      • Task

        Task(TaskType type, Array<TaskType> dependencies)
        Constructor which uses unique id for each task (allows parallel execution of tasks of the same type)
    • Method Detail

      • getSoftDependencies

        @NonNull() Set<TaskType> getSoftDependencies()

        Return set of "soft" dependencies for this task.That means task will wait for these dependencies only in case we havepending or running tasks of such types in the queue.If no such tasks are in the queue when you add this task - these dependencies are ignored.

        As example all events must wait for conversion if we have that in the queue(e.g. we have long list of tasks in result of no internet).However, events with counter 0 must wait for conversion even if it's not yet started(SDK start() not called but init() called)

      • getRetryCount

         final int getRetryCount()

        Indicates number of times task was executed, INCLUDING the initial try.E.g. if task succeed from the first try - this will return 1.

      • addDependency

         final void addDependency(TaskType dependency)

        Adds new dependency to this type, duplicated types are ignored.

        N.B. This will take effect only before task is added to the Queue

      • addSoftDependency

         final void addSoftDependency(TaskType dependency)

        Adds new soft dependency to this type, duplicated types are ignored.

        E.g. Useful for waiting for conversion to be done if have no internet.

      • getResult

        @Nullable() abstract Result getResult()

        Task should store result of it's execution if applicable and return with this method

      • compareTo

         final int compareTo(Task<out Object> o)
        Parameters:
        o - task that given task is compared to