Class BasicExecutor
java.lang.Object
uk.ac.manchester.spinnaker.front_end.BasicExecutor
- All Implemented Interfaces:
AutoCloseable
public class BasicExecutor extends Object implements AutoCloseable
A thread pool designed for simple task execution with combining of
exceptions.
- Author:
- Donal Fellows
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BasicExecutor.SimpleCallable
The type of task that this executor can run.static class
BasicExecutor.Tasks
Holds the future results of the submitted tasks. -
Constructor Summary
Constructors Constructor Description BasicExecutor(int parallelSize)
Create an instance of the pool. -
Method Summary
Modifier and Type Method Description void
close()
BasicExecutor.Tasks
submitTasks(Iterable<BasicExecutor.SimpleCallable> tasks)
Submit some tasks to the pool.<T> BasicExecutor.Tasks
submitTasks(Collection<T> items, Function<T,BasicExecutor.SimpleCallable> taskMapper)
Submit some tasks to the pool.<T> BasicExecutor.Tasks
submitTasks(Stream<T> items, Function<T,BasicExecutor.SimpleCallable> taskMapper)
Submit some tasks to the pool.BasicExecutor.Tasks
submitTasks(Stream<BasicExecutor.SimpleCallable> tasks)
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:
close
in interfaceAutoCloseable
- Throws:
InterruptedException
-