public interface WorkerExecutor
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') ] }
An instance of the executor can be injected into a task by annotating a public constructor or property getter method with javax.inject.Inject
.
Modifier and Type | Method | Description |
---|---|---|
void |
await() |
Blocks until all work associated with the current build operation is complete.
|
void |
submit(Class<? extends Runnable> actionClass,
Action<? super WorkerConfiguration> configAction) |
Submits a piece of work to be executed asynchronously.
|
void submit(Class<? extends Runnable> actionClass, Action<? super WorkerConfiguration> configAction)
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.void await() throws WorkerExecutionException
WorkerExecutionException
- when a failure occurs while executing the work.