Class BusyExecutor


  • public class BusyExecutor
    extends Object
    Executor with busy run support. Can run any tasks while active and safelly wait untill they stopped.
    • Method Detail

      • activate

        public void activate()
        Allow operations.
      • deactivate

        public void deactivate()
        Stop all running tasks. Block new task scheduling, execute cancell runnable and wait till each task stops.
      • busyRun

        public boolean busyRun​(Runnable r)
        Run task on busy lock.
        Parameters:
        r - Task to run.
        Returns:
        true if task was succesfully scheduled, false - otherwise (due to inactive state).
      • submit

        public CompletableFuture<Boolean> submit​(Runnable r)
        Submit task to execute in thread pool under busy lock. Task surrounded with try/catch and if it's complete with any exception - resulting future will return
        Parameters:
        r - Task to execute.
        Returns:
        Completable future with executed flag in result.
      • execute

        public void execute​(Runnable r)
        Execute task in thread pool under busy lock.
        Parameters:
        r - Task to execute.
      • execute

        public void execute​(CancellableTask ct)
        Execute cancellable task in thread pool under busy lock. Track task to cancel on executor stop.
        Parameters:
        ct - Cancellable task to execute.