Interface ExecutionService

    • Method Detail

      • getDefaultExecutor

        @NonNull
        Executor getDefaultExecutor()
        Get the main executor. It is guaranteed to be a single thread. Suitable for any task that doesn't take a long time to complete.
        Returns:
        the main executor.
      • getSerialExecutor

        @NonNull
        ExecutionService.CloseableExecutor getSerialExecutor()
        Get a new, serial executor. Not a single thread but does guarantee serial execution. Suitable for heavyweight that must be executed in order. That is most of them.
        Returns:
        a serial executor.
      • getConcurrentExecutor

        @NonNull
        ExecutionService.CloseableExecutor getConcurrentExecutor()
        Get the concurrent execution service. Executes tasks on a multi-threaded Executor. Suitable for heavyweight tasks. There is no guarantee for order of execution.
        Returns:
        the background thread-pool executor.
      • postDelayedOnExecutor

        @NonNull
        ExecutionService.Cancellable postDelayedOnExecutor​(long delayMs,
                                                           @NonNull
                                                           Executor executor,
                                                           @NonNull
                                                           Runnable task)
        Run the passed task on the passed executor, after a delay
        Parameters:
        delayMs - delay before posting the task. There may be additional queue delays in the executor.
        executor - a executor on which to execute the task.
        task - the task to be executed.
        Returns:
        a cancellable task
      • cancelDelayedTask

        void cancelDelayedTask​(@NonNull
                               ExecutionService.Cancellable future)
        Best effort cancellation of a delayed task.
        Parameters:
        future - object returned by a previous call to postDelayedOnExecutor.