use of org.gradle.internal.operations.BuildOperationWorkerRegistry.Operation in project gradle by gradle.
the class DefaultWorkerExecutor method submit.
private void submit(final WorkerAction action, final Serializable[] params, final File workingDir, final ForkMode fork, final DaemonForkOptions daemonForkOptions) {
final Operation currentWorkerOperation = buildOperationWorkerRegistry.getCurrent();
final BuildOperationExecutor.Operation currentBuildOperation = buildOperationExecutor.getCurrentOperation();
ListenableFuture<DefaultWorkResult> workerDaemonResult = executor.submit(new Callable<DefaultWorkResult>() {
@Override
public DefaultWorkResult call() throws Exception {
try {
WorkSpec spec = new ParamSpec(params);
WorkerFactory workerFactory = fork == ForkMode.ALWAYS ? workerDaemonFactory : workerInProcessFactory;
Worker worker = workerFactory.getWorker(workerProtocolImplementationClass, workingDir, daemonForkOptions);
return worker.execute(action, spec, currentWorkerOperation, currentBuildOperation);
} catch (Throwable t) {
throw new WorkExecutionException(action.getDisplayName(), t);
}
}
});
registerAsyncWork(action.getDisplayName(), workerDaemonResult);
}
use of org.gradle.internal.operations.BuildOperationWorkerRegistry.Operation in project gradle by gradle.
the class InProcessWorkerFactory method getWorker.
@Override
public Worker getWorker(Class<? extends WorkerProtocol> workerImplementationClass, File workingDir, final DaemonForkOptions forkOptions) {
return new Worker() {
@Override
public <T extends WorkSpec> DefaultWorkResult execute(WorkerAction<T> action, T spec) {
return execute(action, spec, buildOperationWorkerRegistry.getCurrent(), buildOperationExecutor.getCurrentOperation());
}
@Override
public <T extends WorkSpec> DefaultWorkResult execute(final WorkerAction<T> action, final T spec, Operation parentWorkerOperation, BuildOperationExecutor.Operation parentBuildOperation) {
BuildOperationWorkerRegistry.Completion workerLease = parentWorkerOperation.operationStart();
BuildOperationDetails buildOperation = BuildOperationDetails.displayName(action.getDisplayName()).parent(parentBuildOperation).build();
try {
return buildOperationExecutor.run(buildOperation, new Transformer<DefaultWorkResult, BuildOperationContext>() {
@Override
public DefaultWorkResult transform(BuildOperationContext buildOperationContext) {
return executeInWorkerClassLoader(action, spec, forkOptions);
}
});
} finally {
workerLease.operationFinish();
}
}
};
}
Aggregations