Package dev.getelements.elements.rt
Class SimpleTaskService
java.lang.Object
dev.getelements.elements.rt.SimpleTaskService
- All Implemented Interfaces:
TaskService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
finishWithError
(TaskId taskId, Throwable error) Fails a task with the suppliedThrowable
, indicating an error.boolean
finishWithResult
(TaskId taskId, Object result) Finishes a task with the supplied result.void
Registers a newTaskId
and set of consumers to handle the results.void
start()
Starts theTaskService
and makes it available to begin accepting tasks.void
stop()
Stops theTaskService
and makes it unavailable to accept tasks.
-
Constructor Details
-
SimpleTaskService
public SimpleTaskService()
-
-
Method Details
-
start
public void start()Description copied from interface:TaskService
Starts theTaskService
and makes it available to begin accepting tasks.- Specified by:
start
in interfaceTaskService
-
stop
public void stop()Description copied from interface:TaskService
Stops theTaskService
and makes it unavailable to accept tasks. Andy pending tasks are completed with an exception and all references cleared.- Specified by:
stop
in interfaceTaskService
-
register
public void register(TaskId taskId, Consumer<Object> consumer, Consumer<Throwable> throwableTConsumer) Description copied from interface:TaskService
Registers a newTaskId
and set of consumers to handle the results.- Specified by:
register
in interfaceTaskService
- Parameters:
taskId
- theTaskId
consumer
- theConsumer
for the result.throwableTConsumer
-
-
finishWithResult
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 thatTaskId
. 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 interfaceTaskService
- Parameters:
taskId
- theTaskId
result
- theObject
that is the result of completing the task
-
finishWithError
Description copied from interface:TaskService
Fails a task with the suppliedThrowable
, indicating an error. In completing the task, references are immediately cleared and no further messages can be sent to thatTaskId
. 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 interfaceTaskService
- Parameters:
taskId
- theTaskId
error
- theThrowable
that is the result of failing the task
-