Example usage for io.netty.util.internal ConcurrentSet add

List of usage examples for io.netty.util.internal ConcurrentSet add

Introduction

In this page you can find the example usage for io.netty.util.internal ConcurrentSet add.

Prototype

@Override
    public boolean add(E o) 

Source Link

Usage

From source file:de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler.java

/**
 * Gets all Connections for a Relay/*from w w  w.j av a 2s.co  m*/
 */
@Override
public ConcurrentSet<IConnectionPair> getConnectionsFor(BlockPos relay, World world) {
    ConcurrentSet<IConnectionPair> allPairs = new ConcurrentSet<IConnectionPair>();
    for (Network aNetwork : WorldData.getDataForWorld(world).laserRelayNetworks) {
        for (IConnectionPair pair : aNetwork.connections) {
            if (pair.contains(relay)) {
                allPairs.add(pair);
            }
        }
    }
    return allPairs;
}

From source file:org.apache.reef.tests.applications.vortex.addone.AddOneCallbackTestStart.java

License:Apache License

/**
 * Test correctness of a simple vector calculation on Vortex, checking results with callbacks.
 *//*from ww w .j a va 2s .com*/
@Override
public void start(final VortexThreadPool vortexThreadPool) {
    final Vector<Integer> inputVector = new Vector<>();
    final int expectedCallbacks = 1000;
    final CountDownLatch latch = new CountDownLatch(expectedCallbacks);
    final ConcurrentSet<Integer> outputSet = new ConcurrentSet<>();
    for (int i = 0; i < expectedCallbacks; i++) {
        inputVector.add(i);
    }

    final List<VortexFuture<Integer>> futures = new ArrayList<>();
    final AddOneFunction addOneFunction = new AddOneFunction();

    for (final int i : inputVector) {
        futures.add(vortexThreadPool.submit(addOneFunction, i, new EventHandler<Integer>() {
            @Override
            public void onNext(final Integer value) {
                outputSet.add(value - 1);
                latch.countDown();
            }
        }));
    }

    try {
        latch.await();
    } catch (InterruptedException e) {
        e.printStackTrace();
        Assert.fail();
    }

    Assert.assertTrue(outputSet.containsAll(inputVector));
    Assert.assertTrue(inputVector.containsAll(outputSet));
}