use of org.gradle.internal.concurrent.StoppableExecutor in project gradle by gradle.
the class ParallelTaskPlanExecutor method process.
@Override
public void process(TaskExecutionPlan taskExecutionPlan, Action<? super TaskInternal> taskWorker) {
StoppableExecutor executor = executorFactory.create("Task worker");
try {
startAdditionalWorkers(taskExecutionPlan, taskWorker, executor);
taskWorker(taskExecutionPlan, taskWorker, buildOperationWorkerRegistry).run();
taskExecutionPlan.awaitCompletion();
} finally {
executor.stop();
}
}
use of org.gradle.internal.concurrent.StoppableExecutor in project gradle by gradle.
the class TcpIncomingConnector method accept.
public ConnectionAcceptor accept(Action<ConnectCompletion> action, boolean allowRemote) {
final ServerSocketChannel serverSocket;
int localPort;
try {
serverSocket = ServerSocketChannel.open();
serverSocket.socket().bind(new InetSocketAddress(addressFactory.getLocalBindingAddress(), 0));
localPort = serverSocket.socket().getLocalPort();
} catch (Exception e) {
throw UncheckedException.throwAsUncheckedException(e);
}
UUID id = idGenerator.generateId();
List<InetAddress> addresses = addressFactory.getCommunicationAddresses();
final Address address = new MultiChoiceAddress(id, localPort, addresses);
LOGGER.debug("Listening on {}.", address);
final StoppableExecutor executor = executorFactory.create("Incoming " + (allowRemote ? "remote" : "local") + " TCP Connector on port " + localPort);
executor.execute(new Receiver(serverSocket, action, allowRemote));
return new ConnectionAcceptor() {
public Address getAddress() {
return address;
}
public void requestStop() {
CompositeStoppable.stoppable(serverSocket).stop();
}
public void stop() {
requestStop();
executor.stop();
}
};
}
Aggregations