Class DelegatingExecutor

All Implemented Interfaces:
AsyncCloseable, Executor, ListenableAsyncCloseable, Executor, TimeSource

public class DelegatingExecutor extends DelegatingListenableAsyncCloseable<Executor> implements Executor
An Executor that simply delegates all calls to another Executor.
  • Constructor Details

    • DelegatingExecutor

      protected DelegatingExecutor(Executor delegate)
      New instance.
      Parameters:
      delegate - Executor to delegate all calls to.
  • Method Details

    • delegate

      protected Executor delegate()
      Get the Executor that this class delegates to.
      Overrides:
      delegate in class DelegatingListenableAsyncCloseable<Executor>
      Returns:
      the Executor that this class delegates to.
    • execute

      public Cancellable execute(Runnable task) throws RejectedExecutionException
      Description copied from interface: Executor
      Executes the passed task as soon as possible.
      Specified by:
      execute in interface Executor
      Parameters:
      task - to execute.
      Returns:
      Cancellable to cancel the task if not yet executed.
      Throws:
      RejectedExecutionException - If the task is rejected.
    • schedule

      public Cancellable schedule(Runnable task, long delay, TimeUnit unit) throws RejectedExecutionException
      Description copied from interface: Executor
      Executes the passed task after delay amount of units time has passed.

      Note this method is not guaranteed to provide real time execution. For example implementations are free to consolidate tasks into time buckets to reduce the overhead of timer management at the cost of reduced timer fidelity.

      Specified by:
      schedule in interface Executor
      Parameters:
      task - to execute.
      delay - The time duration that is allowed to elapse before task is executed.
      unit - The units for delay.
      Returns:
      Cancellable to cancel the task if not yet executed.
      Throws:
      RejectedExecutionException - If the task is rejected.
    • schedule

      public Cancellable schedule(Runnable task, Duration delay) throws RejectedExecutionException
      Description copied from interface: Executor
      Executes the passed task after delay amount time has passed.

      Note this method is not guaranteed to provide real time execution. For example implementations are free to consolidate tasks into time buckets to reduce the overhead of timer management at the cost of reduced timer fidelity.

      Specified by:
      schedule in interface Executor
      Parameters:
      task - to execute.
      delay - The time duration that is allowed to elapse before task is executed.
      Returns:
      Cancellable to cancel the task if not yet executed.
      Throws:
      RejectedExecutionException - If the task is rejected.
    • timer

      public Completable timer(long delay, TimeUnit unit)
      Description copied from interface: Executor
      Creates a new Completable that will complete after the time duration expires.
      Specified by:
      timer in interface Executor
      Parameters:
      delay - The time duration which is allowed to elapse between subscribe and termination.
      unit - The units for duration.
      Returns:
      a new Completable that will complete after the time duration expires.
      See Also:
    • timer

      public Completable timer(Duration delay)
      Description copied from interface: Executor
      Creates a new Completable that will complete after the time duration expires.
      Specified by:
      timer in interface Executor
      Parameters:
      delay - The time duration which is allowed to elapse between subscribe and termination.
      Returns:
      a new Completable that will complete after the time duration expires.
      See Also:
    • submit

      public Completable submit(Runnable runnable)
      Description copied from interface: Executor
      Create a new Completable that executes the passed Runnable on each subscribe.
      Specified by:
      submit in interface Executor
      Parameters:
      runnable - The Runnable to execute on each subscribe.
      Returns:
      a new Completable that executes a Runnable on each subscribe.
    • submitRunnable

      public Completable submitRunnable(Supplier<Runnable> runnableSupplier)
      Description copied from interface: Executor
      Creates a new Completable that creates and executes a Runnable when subscribed to.
      Specified by:
      submitRunnable in interface Executor
      Parameters:
      runnableSupplier - Supplier to create a new Runnable for every subscribe of the returned Completable.
      Returns:
      A new Completable that creates and executes a new Runnable using runnableSupplier for every subscribe.
    • submit

      public <T> Single<T> submit(Callable<? extends T> callable)
      Description copied from interface: Executor
      Creates a new Single that creates and executes the passed Callable when subscribed to.
      Specified by:
      submit in interface Executor
      Type Parameters:
      T - Type of the Single.
      Parameters:
      callable - The Callable to execute on each subscribe.
      Returns:
      a new Single that obtains a Callable from callableSupplier and executes it on each subscribe.
    • submitCallable

      public <T> Single<T> submitCallable(Supplier<? extends Callable<? extends T>> callableSupplier)
      Description copied from interface: Executor
      Create a new Single that obtains a Callable from callableSupplier and executes on each subscribe.
      Specified by:
      submitCallable in interface Executor
      Type Parameters:
      T - Type of the Single.
      Parameters:
      callableSupplier - Supplier to create a new Callable for every call to subscribe to the returned Single.
      Returns:
      A new Single that creates and executes a new Callable using callableSupplier for every subscribe.
    • currentTime

      public long currentTime(TimeUnit unit)
      Description copied from interface: TimeSource
      Returns the internal clock time in the specified unit.
      Specified by:
      currentTime in interface Executor
      Specified by:
      currentTime in interface TimeSource
      Parameters:
      unit - the time unit to calculate
      Returns:
      the internal clock time in the specified unit.