Class BasicExecutor
java.lang.Object
uk.ac.manchester.spinnaker.front_end.BasicExecutor
- All Implemented Interfaces:
AutoCloseable
A thread pool designed for simple task execution with combining of
exceptions.
- Author:
- Donal Fellows
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe type of task that this executor can run.static final classHolds the future results of the submitted tasks. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Submit some tasks to the pool.submitTasks(Collection<T> items, Function<T, BasicExecutor.SimpleCallable> taskMapper) Submit some tasks to the pool.submitTasks(Stream<T> items, Function<T, BasicExecutor.SimpleCallable> taskMapper) Submit some tasks to the pool.Submit some tasks to the pool.
-
Constructor Details
-
BasicExecutor
Create an instance of the pool.- Parameters:
parallelSize- The number of threads to use inside the pool.
-
-
Method Details
-
submitTasks
Submit some tasks to the pool.- Parameters:
tasks- The tasks to submit. Should not be a parallel stream.- Returns:
- The future holding the results of the execution.
-
submitTasks
public <T> BasicExecutor.Tasks submitTasks(Stream<T> items, Function<T, BasicExecutor.SimpleCallable> taskMapper) Submit some tasks to the pool.- Type Parameters:
T- The type of the items.- Parameters:
items- The items representing tasks to submit. Should not be a parallel stream.taskMapper- How to convert the item to a task.- Returns:
- The future holding the results of the execution.
-
submitTasks
public <T> BasicExecutor.Tasks submitTasks(Collection<T> items, Function<T, BasicExecutor.SimpleCallable> taskMapper) Submit some tasks to the pool.- Type Parameters:
T- The type of the items.- Parameters:
items- The items representing tasks to submit.taskMapper- How to convert the item to a task.- Returns:
- The future holding the results of the execution.
-
submitTasks
Submit some tasks to the pool.- Parameters:
tasks- The tasks to submit.- Returns:
- The future holding the results of the execution.
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
InterruptedException
-