api / org.gradle.workers / WorkerExecutor

WorkerExecutor

@Incubating interface WorkerExecutor

Allows work to be submitted for asynchronous execution. This api allows for safe, concurrent execution of work items and enables:

Work should be submitted with a Runnable class representing the implementation of the unit of work and an action to configure the unit of work (via WorkerConfiguration).
 workerExecutor.submit(RunnableWorkImpl.class) { WorkerConfiguration conf -> // Set the isolation mode for the worker conf.isolationMode = IsolationMode.NONE // Set up the constructor parameters for the unit of work conf.params = [ "foo", file('bar') ] } 

Since
3.5

Functions

await

abstract fun await(): Unit

Blocks until all work associated with the current build operation is complete. Note that when using this method inside a task action, it will block completion of the task action until all submitted work is complete. This means that other tasks from the same project cannot be run in parallel while the task action is still executing.

submit

abstract fun submit(actionClass: Class<out Runnable>, configAction: Action<in WorkerConfiguration>): Unit

Submits a piece of work to be executed asynchronously. Execution of the work may begin immediately. Work configured with IsolationMode#PROCESS will execute in an idle daemon that meets the requirements set in the WorkerConfiguration. If no idle daemons are available, a new daemon will be started. Any errors will be thrown from #await() or from the surrounding task action if #await() is not used.