Search in sources :

Example 1 with WorkerConfiguration

use of org.gradle.workers.WorkerConfiguration in project gradle by gradle.

the class DefaultWorkerExecutor method submit.

@Override
public void submit(Class<? extends Runnable> actionClass, Action<WorkerConfiguration> configAction) {
    WorkerConfiguration configuration = new DefaultWorkerConfiguration(fileResolver);
    configAction.execute(configuration);
    String description = configuration.getDisplayName() != null ? configuration.getDisplayName() : actionClass.getName();
    WorkerAction action = new WorkerRunnableAction(description, actionClass);
    submit(action, configuration.getParams(), configuration.getForkOptions().getWorkingDir(), configuration.getForkMode(), getDaemonForkOptions(actionClass, configuration));
}
Also used : WorkerConfiguration(org.gradle.workers.WorkerConfiguration)

Example 2 with WorkerConfiguration

use of org.gradle.workers.WorkerConfiguration in project gradle by gradle.

the class DefaultWorkerExecutor method submit.

@Override
public void submit(Class<? extends Runnable> actionClass, Action<? super WorkerConfiguration> configAction) {
    WorkerConfiguration configuration = new DefaultWorkerConfiguration(fileResolver);
    configAction.execute(configuration);
    String description = configuration.getDisplayName() != null ? configuration.getDisplayName() : actionClass.getName();
    // Serialize parameters in this thread prior to starting work in a separate thread
    ActionExecutionSpec spec;
    try {
        spec = new SerializingActionExecutionSpec(actionClass, description, configuration.getForkOptions().getWorkingDir(), configuration.getParams());
    } catch (Throwable t) {
        throw new WorkExecutionException(description, t);
    }
    submit(spec, configuration.getIsolationMode(), getDaemonForkOptions(actionClass, configuration));
}
Also used : WorkerConfiguration(org.gradle.workers.WorkerConfiguration)

Example 3 with WorkerConfiguration

use of org.gradle.workers.WorkerConfiguration in project gradle by gradle.

the class WorkerTask method executeTask.

@TaskAction
public void executeTask() {
    for (int i = 0; i < outputSize; i++) {
        final int index = i;
        getWorkerExecutor().submit(UnitOfWork.class, new Action<WorkerConfiguration>() {

            @Override
            public void execute(WorkerConfiguration workerConfiguration) {
                workerConfiguration.setDisplayName(getName() + " work for " + index);
                workerConfiguration.setIsolationMode(isolationMode);
                File outputFile = new File(outputDir, "out-" + index + ".txt");
                workerConfiguration.setParams(index, outputFile);
            }
        });
    }
}
Also used : WorkerConfiguration(org.gradle.workers.WorkerConfiguration) File(java.io.File) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

WorkerConfiguration (org.gradle.workers.WorkerConfiguration)3 File (java.io.File)1 TaskAction (org.gradle.api.tasks.TaskAction)1