Class DelegatingExecutor

    • Constructor Detail

      • DelegatingExecutor

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

      • execute

        public Cancellable execute​(java.lang.Runnable task)
                            throws java.util.concurrent.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:
        java.util.concurrent.RejectedExecutionException - If the task is rejected.
      • schedule

        public Cancellable schedule​(java.lang.Runnable task,
                                    long delay,
                                    java.util.concurrent.TimeUnit unit)
                             throws java.util.concurrent.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:
        java.util.concurrent.RejectedExecutionException - If the task is rejected.
      • schedule

        public Cancellable schedule​(java.lang.Runnable task,
                                    java.time.Duration delay)
                             throws java.util.concurrent.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:
        java.util.concurrent.RejectedExecutionException - If the task is rejected.
      • timer

        public Completable timer​(long delay,
                                 java.util.concurrent.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:
        ReactiveX Timer.
      • timer

        public Completable timer​(java.time.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:
        ReactiveX Timer.
      • submit

        public Completable submit​(java.lang.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​(java.util.function.Supplier<java.lang.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​(java.util.concurrent.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​(java.util.function.Supplier<? extends java.util.concurrent.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.
      • closeAsyncGracefully

        public Completable closeAsyncGracefully()
        Description copied from interface: AsyncCloseable
        Used to close/shutdown a resource, similar to AsyncCloseable.closeAsync(), but attempts to cleanup state before abruptly closing. This provides a hint that implementations can use to stop accepting new work and finish in flight work. This method is implemented on a "best effort" basis and may be equivalent to AsyncCloseable.closeAsync().

        Note: Implementations may or may not apply a timeout for this operation to complete, if a caller does not want to wait indefinitely, and are unsure if the implementation applies a timeout, it is advisable to apply a timeout and force a call to AsyncCloseable.closeAsync().

        Specified by:
        closeAsyncGracefully in interface AsyncCloseable
        Returns:
        A Completable that is notified once the close is complete.