Package groovyx.gpars.dataflow

Examples of groovyx.gpars.dataflow.DataflowVariable


        });
        client.start();
    }

    protected <T> DataflowVariable<T> getPromise(ConcurrentMap<String, DataflowVariable<T>> registry, String name, String host, int port, SerialMsg requestMsg) {
        DataflowVariable remoteVariable = registry.get(name);
        if (remoteVariable == null) {
            DataflowVariable newRemoteVariable = new DataflowVariable<>();
            remoteVariable = registry.putIfAbsent(name, newRemoteVariable);
            if (remoteVariable == null) {
                createRequest(host, port, requestMsg);
                remoteVariable = newRemoteVariable;
            }
View Full Code Here


     *
     * @param callable The task body to run
     * @return A DataflowVariable, which gets assigned the value returned from the supplied code
     */
    public final <T> Promise<T> task(final Callable<T> callable) {
        final DataflowVariable result = new DataflowVariable();
        threadPool.execute(new Runnable() {
            @SuppressWarnings("OverlyBroadCatchBlock")
            @Override
            public void run() {
                Dataflow.activeParallelGroup.set(PGroup.this);
                try {
                    //noinspection OverlyBroadCatchBlock
                    try {
                        result.bind(callable.call());
                    } catch (Throwable e) {
                        result.bind(e);
                    }
                } finally {
                    Dataflow.activeParallelGroup.remove();
                }
            }
View Full Code Here

     * @param code The task body to run
     * @return A DataflowVariable, which gets bound to null once the supplied code finishes
     */
    public final Promise<Object> task(final Runnable code) {
        if (code instanceof Closure) return task((Closure) code);
        final DataflowVariable result = new DataflowVariable();
        threadPool.execute(new Runnable() {
            @Override
            public void run() {
                Dataflow.activeParallelGroup.set(PGroup.this);
                try {
                    try {
                        code.run();
                        result.bind(null);
                    } catch (Throwable e) {
                        result.bind(e);
                    }
                } finally {
                    Dataflow.activeParallelGroup.remove();
                }
            }
View Full Code Here

            throw new IllegalArgumentException("Cannot run whenAllBound(), since the number of promises does not match the number of arguments to the supplied closure.");
        }
        for (final Promise promise : promises) {
            promise.touch();
        }
        final DataflowVariable result = new DataflowVariable();
        whenAllBound(promises, 0, new ArrayList<Object>(promises.size()), result, code, errorHandler);
        return result;
    }
View Full Code Here

TOP

Related Classes of groovyx.gpars.dataflow.DataflowVariable

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.