Worker Executor
Allows work to be submitted for asynchronous execution. This api allows for safe, concurrent execution of work items and enables:
- Parallel execution of work items within a single task
- Execution in isolated contexts such as an isolated classloader or even a separate process
- Safe execution of multiple tasks in parallel
Work should be submitted with a WorkAction class representing the implementation of the unit of work and an action to configure the parameters of the unit of work (via WorkParameters).
workerExecutor.noIsolation().submit(MyWorkActionImpl.class) { MyWorkParameters parameters ->
parameters.inputFile = project.file('foo')
parameters.outputFile = project.layout.buildDirectory.file('bar')
}
Content copied to clipboard
An instance of the executor can be injected into a task by annotating a public constructor or property getter method with javax.inject.Inject
.
Since
3.5
Functions
Link copied to clipboard
Creates a WorkQueue to submit work for asynchronous execution with an isolated classloader.
Creates a WorkQueue to submit work for asynchronous execution with an isolated classloader and the requirements specified in the supplied ClassLoaderWorkerSpec.
Link copied to clipboard
Creates a WorkQueue to submit work for asynchronous execution with no isolation.
Creates a WorkQueue to submit work for asynchronous execution with no isolation and the requirements specified in the supplied WorkerSpec.
Link copied to clipboard
Creates a WorkQueue to submit work for asynchronous execution in a daemon process.