gradle
8.2

# WorkerExecutor

interface WorkerExecutor

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`.

## Functions

await
Link copied to clipboard
abstract fun await()
Blocks until all work associated with the current build operation is complete.
classLoaderIsolation
Link copied to clipboard
abstract fun classLoaderIsolation(): WorkQueue
Creates a WorkQueue to submit work for asynchronous execution with an isolated classloader.
abstract fun classLoaderIsolation(action: Action<out Any>): WorkQueue
Creates a WorkQueue to submit work for asynchronous execution with an isolated classloader and the requirements specified in the supplied ClassLoaderWorkerSpec.
noIsolation
Link copied to clipboard
abstract fun noIsolation(): WorkQueue
Creates a WorkQueue to submit work for asynchronous execution with no isolation.
abstract fun noIsolation(action: Action<out Any>): WorkQueue
Creates a WorkQueue to submit work for asynchronous execution with no isolation and the requirements specified in the supplied WorkerSpec.
processIsolation
Link copied to clipboard
abstract fun processIsolation(): WorkQueue
abstract fun processIsolation(action: Action<out Any>): WorkQueue
Creates a WorkQueue to submit work for asynchronous execution in a daemon process.