Package org.gradle.internal.concurrent

Examples of org.gradle.internal.concurrent.StoppableExecutor


            this.executorFactory = executorFactory;
            this.name = name;
        }

        public void stop() {
            StoppableExecutor executor;
            lock.lock();
            try {
                executor = this.executor;
            } finally {
                lock.unlock();
            }
            if (executor != null) {
                executor.stop();
            }
        }
View Full Code Here


                stopConsuming();
            }
        }

        protected void stopConsuming() {
            StoppableExecutor executor;
            lock.lock();
            try {
                queue.clear();
                removed = true;
                condition.signalAll();
                executor = this.executor;
            } finally {
                lock.unlock();
            }
            if (executor != null) {
                executor.stop();
            }
        }
View Full Code Here

        this.executorCount = numberOfParallelExecutors;
    }

    public void process(final TaskExecutionPlan taskExecutionPlan, final TaskExecutionListener taskListener) {
        StoppableExecutor executor = executorFactory.create("Task worker");
        try {
            startAdditionalWorkers(taskExecutionPlan, taskListener, executor);
            taskWorker(taskExecutionPlan, taskListener).run();
            taskExecutionPlan.awaitCompletion();
        } finally {
            executor.stop();
        }
    }
View Full Code Here

        this.nodeName = nodeName;
        this.executorFactory = executorFactory;
        this.idGenerator = idGenerator;
        this.messagingClassLoader = messagingClassLoader;
        failureHandler = new DiscardingFailureHandler<Object>(LoggerFactory.getLogger(MessageHub.class));
        StoppableExecutor executor = executorFactory.create(displayName + " message router");
        executors.add(executor);
        router = new Router(executor, failureHandler);

        incomingExecutor = executorFactory.create(displayName + " worker");
        executors.add(incomingExecutor);
View Full Code Here

        try {
            ProtocolStack<Message> outgoing = outgoingBroadcasts.get(channel);
            if (outgoing == null) {
                Protocol<Message> broadcastProtocol = new BroadcastSendProtocol();
                Protocol<Message> sendProtocol = new SendProtocol(idGenerator.generateId(), nodeName, channel);
                StoppableExecutor executor = executorFactory.create(displayName + " outgoing broadcast " + channel);
                executors.add(executor);
                outgoing = new ProtocolStack<Message>(executor, failureHandler, failureHandler, broadcastProtocol, sendProtocol);
                outgoingBroadcasts.put(channel, outgoing);

                AsyncConnection<Message> outgoingEndpoint = router.createLocalConnection();
View Full Code Here

    private final Set<Stoppable> executors = new HashSet<Stoppable>();

    public AsyncConnectionAdapter(Connection<T> connection, DispatchFailureHandler<? super T> dispatchFailureHandler, ExecutorFactory executor, Protocol<T>... protocols) {
        this.connection = connection;

        StoppableExecutor outgoingExecutor = executor.create(String.format("%s send", connection));
        executors.add(outgoingExecutor);
        outgoing = new AsyncDispatch<T>(outgoingExecutor);
        outgoing.dispatchTo(new FailureHandlingDispatch<T>(connection, dispatchFailureHandler));

        StoppableExecutor dispatchExecutor = executor.create(String.format("%s dispatch", connection));
        executors.add(dispatchExecutor);
        stack = new ProtocolStack<T>(dispatchExecutor, dispatchFailureHandler, dispatchFailureHandler, protocols);
        stack.getBottom().dispatchTo(outgoing);

        StoppableExecutor incomingExecutor = executor.create(String.format("%s receive", connection));
        executors.add(incomingExecutor);
        incoming = new AsyncReceive<T>(incomingExecutor);
        incoming.dispatchTo(stack.getBottom());
        incoming.receiveFrom(new ConnectionReceive<T>(connection));
    }
View Full Code Here

        Object id = idGenerator.generateId();
        List<InetAddress> addresses = allowRemote ? addressFactory.findRemoteAddresses() : addressFactory.findLocalAddresses();
        final Address address = new MultiChoiceAddress(id, localPort, addresses);
        LOGGER.debug("Listening on {}.", address);

        final StoppableExecutor executor = executorFactory.create(String.format("Incoming %s TCP Connector on port %s", allowRemote ? "remote" : "local", 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();
            }
        };
    }
View Full Code Here

TOP

Related Classes of org.gradle.internal.concurrent.StoppableExecutor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.