WorkerExecutor

@ServiceScope(value = Project::class)
interface WorkerExecutor(source)

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')
     }

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
abstract fun await()
Blocks until all work associated with the current build operation is complete.
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
abstract fun noIsolation(): WorkQueue
Creates a WorkQueue to submit work for asynchronous execution with no isolation.
abstract fun noIsolation(action: Action<in WorkerSpec>): WorkQueue
Creates a WorkQueue to submit work for asynchronous execution with no isolation and the requirements specified in the supplied WorkerSpec.
Link copied to clipboard
abstract fun processIsolation(): WorkQueue
Creates a WorkQueue to submit work for asynchronous execution in a daemon process.