Slackbot
10/03/2022, 10:04 PMChris Lee
10/03/2022, 10:35 PM.close()
for those that are AutoCloseable
. The listeners are added at registration time, and presumably are called in that order.
private <T extends BuildService<P>, P extends BuildServiceParameters> BuildServiceProvider<T, P> doRegister(
String name,
Class<T> implementationType,
@Nullable P parameters,
Integer maxParallelUsages,
NamedDomainObjectSet<BuildServiceRegistration<?, ?>> registrations
) {
BuildServiceProvider<T, P> provider = new BuildServiceProvider<>(
buildIdentifier,
name,
implementationType,
parameters,
isolationScheme,
instantiatorFactory.injectScheme(),
isolatableFactory,
services,
listener
);
DefaultServiceRegistration<T, P> registration = uncheckedNonnullCast(specInstantiator.newInstance(DefaultServiceRegistration.class, name, parameters, provider));
registration.getMaxParallelUsages().set(maxParallelUsages);
registrations.add(registration);
// TODO - should stop the service after last usage (ie after the last task that uses it) instead of at the end of the build
// TODO - should reuse service across build invocations, until the parameters change (which contradicts the previous item)
listenerManager.addListener(new ServiceCleanupListener(provider));
return provider;
}
Chris Lee
10/03/2022, 10:37 PMfor (ListenerDetails listener : allListeners.values()) {
broadcaster.maybeAdd(listener);
}
Ben Blechman
10/03/2022, 11:21 PMChris Lee
10/03/2022, 11:23 PMCloseable
(instead of AutoCloseable), to avoid the flaky ordering, and then have a build service that listens for the buildFinished event and calls close on the service in the right order.Chris Lee
10/03/2022, 11:24 PMBen Blechman
10/05/2022, 6:09 PMChris Lee
10/05/2022, 6:38 PMclose()
today is triggered on the buildFinished event.