Class SimpleTaskService

java.lang.Object
dev.getelements.elements.rt.SimpleTaskService
All Implemented Interfaces:
TaskService

public class SimpleTaskService extends Object implements TaskService
  • Constructor Details

    • SimpleTaskService

      public SimpleTaskService()
  • Method Details

    • start

      public void start()
      Description copied from interface: TaskService
      Starts the TaskService and makes it available to begin accepting tasks.
      Specified by:
      start in interface TaskService
    • stop

      public void stop()
      Description copied from interface: TaskService
      Stops the TaskService and makes it unavailable to accept tasks. Andy pending tasks are completed with an exception and all references cleared.
      Specified by:
      stop in interface TaskService
    • register

      public void register(TaskId taskId, Consumer<Object> consumer, Consumer<Throwable> throwableTConsumer)
      Description copied from interface: TaskService
      Registers a new TaskId and set of consumers to handle the results.
      Specified by:
      register in interface TaskService
      Parameters:
      taskId - the TaskId
      consumer - the Consumer for the result.
      throwableTConsumer -
    • finishWithResult

      public boolean finishWithResult(TaskId taskId, Object result)
      Description copied from interface: TaskService
      Finishes a task with the supplied result. In completing the task, references are immediately cleared and no further messages can be sent to that TaskId. As not all tasks are registered with a set of listeners, this may simply return false indicating that no listeners were notified.
      Specified by:
      finishWithResult in interface TaskService
      Parameters:
      taskId - the TaskId
      result - the Object that is the result of completing the task
    • finishWithError

      public boolean finishWithError(TaskId taskId, Throwable error)
      Description copied from interface: TaskService
      Fails a task with the supplied Throwable, indicating an error. In completing the task, references are immediately cleared and no further messages can be sent to that TaskId. As not all tasks are registered with a set of listeners, this may simply return false indicating that no listeners were notified.
      Specified by:
      finishWithError in interface TaskService
      Parameters:
      taskId - the TaskId
      error - the Throwable that is the result of failing the task