Package groovyx.gpars

Examples of groovyx.gpars.DataflowMessagingRunnable


        ch2.bind(BigInteger.ZERO);


        final List<DataflowQueue<BigInteger>> calculationInputList = asList(ch1, ch2);
        final List<DataflowQueue<BigInteger>> calculationOutputList = asList(ch3, ch1, ch2);
        final DataflowProcessor op = Dataflow.operator(calculationInputList, calculationOutputList, new DataflowMessagingRunnable(2) {
            long counter = 0L;

            @Override
            protected void doRun(final Object... arguments) {
                final DataflowProcessor owner = getOwningProcessor();
View Full Code Here


        final DataflowQueue stream4 = new DataflowQueue();

        // processor1 waits for value in stream 1 and writes 2*value to stream2
        final List<DataflowQueue> calculationInputList = asList(stream1);
        final List<DataflowQueue> calculationOutputList = asList(stream2);
        final DataflowProcessor processor1 = Dataflow.operator(calculationInputList, calculationOutputList, new DataflowMessagingRunnable(1) {
            @Override
            protected void doRun(final Object... arguments) {
                // Passing calculated value to output stream
                getOwningProcessor().bindOutput(2 * (Integer) arguments[0]);
            }
        });

        assertFalse("Stream2 should not be bound as no value was passed to stream1", stream2.isBound());
        // send values to streams
        stream1.bind(1);


        waitForValue(stream2);
        assertTrue("Stream2 should be bound as value has been calculated by processor1", stream2.isBound());

        // processor2 reads value from stream2 and stream 2 and writes sum to stream 4
        final DataflowProcessor processor2 = Dataflow.operator(asList(stream2, stream3), asList(stream4), new DataflowMessagingRunnable(2) {
            @Override
            protected void doRun(final Object... arguments) {
                getOwningProcessor().bindOutput((Integer) arguments[0] + (Integer) arguments[1]);
            }
        });
View Full Code Here

            final DataflowVariable<? extends Object> partialResult = new DataflowVariable<Object>();
            whenBound(pool, new ThenMessagingRunnable(partialResult, closure));
            partialResults.add(partialResult);
        }
        group.whenAllBound(partialResults,
                new DataflowMessagingRunnable(partialResults.size()) {
                    @Override
                    protected void doRun(final Object... arguments) {
                        result.bind(Arrays.asList(arguments));
                    }
                },
                new DataflowMessagingRunnable(1) {
                    @Override
                    protected void doRun(final Object... arguments) {
                        result.bindError((Throwable) arguments[0]);
                    }
                }
View Full Code Here

TOP

Related Classes of groovyx.gpars.DataflowMessagingRunnable

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.