Search in sources :

Example 1 with CompositeStoppable

use of org.gradle.internal.concurrent.CompositeStoppable in project gradle by gradle.

the class BuildActionsFactory method runBuildAndCloseServices.

private Runnable runBuildAndCloseServices(StartParameter startParameter, DaemonParameters daemonParameters, BuildActionExecuter<BuildActionParameters> executer, ServiceRegistry sharedServices, Object... stopBeforeSharedServices) {
    BuildActionParameters parameters = createBuildActionParamters(startParameter, daemonParameters);
    Stoppable stoppable = new CompositeStoppable().add(stopBeforeSharedServices).add(sharedServices);
    return new RunBuildAction(executer, startParameter, clientMetaData(), getBuildStartTime(), parameters, sharedServices, stoppable);
}
Also used : BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) Stoppable(org.gradle.internal.concurrent.Stoppable) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable)

Example 2 with CompositeStoppable

use of org.gradle.internal.concurrent.CompositeStoppable in project gradle by gradle.

the class BuildActionsFactory method runBuildAndCloseServices.

private Runnable runBuildAndCloseServices(StartParameterInternal startParameter, DaemonParameters daemonParameters, BuildActionExecuter<BuildActionParameters> executer, ServiceRegistry sharedServices, Object... stopBeforeSharedServices) {
    BuildActionParameters parameters = createBuildActionParameters(startParameter, daemonParameters);
    Stoppable stoppable = new CompositeStoppable().add(stopBeforeSharedServices).add(sharedServices);
    return new RunBuildAction(executer, startParameter, clientMetaData(), getBuildStartTime(), parameters, sharedServices, stoppable);
}
Also used : BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) Stoppable(org.gradle.internal.concurrent.Stoppable) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable)

Example 3 with CompositeStoppable

use of org.gradle.internal.concurrent.CompositeStoppable in project gradle by gradle.

the class DefaultWorkerProcess method cleanup.

private void cleanup() {
    CompositeStoppable stoppable;
    lock.lock();
    try {
        stoppable = CompositeStoppable.stoppable(connection, new Stoppable() {

            @Override
            public void stop() {
                execHandle.abort();
            }
        }, acceptor);
    } finally {
        this.connection = null;
        this.acceptor = null;
        lock.unlock();
    }
    stoppable.stop();
}
Also used : CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) Stoppable(org.gradle.internal.concurrent.Stoppable) AsyncStoppable(org.gradle.internal.concurrent.AsyncStoppable) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable)

Example 4 with CompositeStoppable

use of org.gradle.internal.concurrent.CompositeStoppable in project gradle by gradle.

the class BuildActionsFactory method runBuildAndCloseServices.

private Runnable runBuildAndCloseServices(StartParameterInternal startParameter, DaemonParameters daemonParameters, BuildActionExecuter<BuildActionParameters, BuildRequestContext> executer, ServiceRegistry sharedServices, Object... stopBeforeSharedServices) {
    BuildActionParameters parameters = createBuildActionParameters(startParameter, daemonParameters);
    Stoppable stoppable = new CompositeStoppable().add(stopBeforeSharedServices).add(sharedServices);
    return new RunBuildAction(executer, startParameter, clientMetaData(), getBuildStartTime(), parameters, sharedServices, stoppable);
}
Also used : BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) Stoppable(org.gradle.internal.concurrent.Stoppable) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable)

Example 5 with CompositeStoppable

use of org.gradle.internal.concurrent.CompositeStoppable in project gradle by gradle.

the class ServicesSetupBuildActionExecuter method execute.

@Override
public Object execute(BuildAction action, BuildRequestContext requestContext, BuildActionParameters actionParameters, ServiceRegistry contextServices) {
    StartParameter startParameter = action.getStartParameter();
    final ServiceRegistry userHomeServices = userHomeServiceRegistry.getServicesFor(startParameter.getGradleUserHomeDir());
    CrossBuildSessionScopeServices crossBuildSessionScopeServices = new CrossBuildSessionScopeServices(contextServices, startParameter);
    try {
        ServiceRegistry buildSessionScopeServices = new BuildSessionScopeServices(userHomeServices, crossBuildSessionScopeServices, startParameter, requestContext, actionParameters.getInjectedPluginClasspath());
        try {
            SessionLifecycleListener sessionLifecycleListener = buildSessionScopeServices.get(ListenerManager.class).getBroadcaster(SessionLifecycleListener.class);
            try {
                sessionLifecycleListener.afterStart();
                return delegate.execute(action, requestContext, actionParameters, buildSessionScopeServices);
            } finally {
                sessionLifecycleListener.beforeComplete();
            }
        } finally {
            CompositeStoppable.stoppable(buildSessionScopeServices).stop();
        }
    } finally {
        new CompositeStoppable().add(new Stoppable() {

            @Override
            public void stop() {
                userHomeServiceRegistry.release(userHomeServices);
            }
        }, crossBuildSessionScopeServices).stop();
    }
}
Also used : StartParameter(org.gradle.StartParameter) CrossBuildSessionScopeServices(org.gradle.internal.service.scopes.CrossBuildSessionScopeServices) SessionLifecycleListener(org.gradle.initialization.SessionLifecycleListener) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) Stoppable(org.gradle.internal.concurrent.Stoppable) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) GradleUserHomeScopeServiceRegistry(org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry) BuildSessionScopeServices(org.gradle.internal.service.scopes.BuildSessionScopeServices) CrossBuildSessionScopeServices(org.gradle.internal.service.scopes.CrossBuildSessionScopeServices) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) ListenerManager(org.gradle.internal.event.ListenerManager)

Aggregations

CompositeStoppable (org.gradle.internal.concurrent.CompositeStoppable)6 Stoppable (org.gradle.internal.concurrent.Stoppable)5 BuildActionParameters (org.gradle.launcher.exec.BuildActionParameters)3 DefaultBuildActionParameters (org.gradle.launcher.exec.DefaultBuildActionParameters)3 File (java.io.File)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 StartParameter (org.gradle.StartParameter)1 SessionLifecycleListener (org.gradle.initialization.SessionLifecycleListener)1 AsyncStoppable (org.gradle.internal.concurrent.AsyncStoppable)1 ListenerManager (org.gradle.internal.event.ListenerManager)1 ServiceRegistry (org.gradle.internal.service.ServiceRegistry)1 BuildSessionScopeServices (org.gradle.internal.service.scopes.BuildSessionScopeServices)1 CrossBuildSessionScopeServices (org.gradle.internal.service.scopes.CrossBuildSessionScopeServices)1 GradleUserHomeScopeServiceRegistry (org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry)1