Examples of CyclicBarrier


Examples of EDU.oswego.cs.dl.util.concurrent.CyclicBarrier

        System.out.println("-- [" + Thread.currentThread().getName() + "] " + msg);
    }


    public void testConcurrentJoins() throws Exception {
        start_connecting=new CyclicBarrier(NUM +1);
        connected=new CyclicBarrier(NUM +1);
        received_all_views=new CyclicBarrier(NUM +1);
        start_disconnecting=new CyclicBarrier(NUM +1);
        disconnected=new CyclicBarrier(NUM +1);

        long start, stop;

        //  create main channel - will be coordinator for JOIN requests
        channel=new JChannel(props);
View Full Code Here

Examples of EDU.oswego.cs.dl.util.concurrent.CyclicBarrier

        System.out.println("-- [" + Thread.currentThread().getName() + "] " + msg);
    }


    public void testConcurrentStartupAndMerging() throws Exception {
        start_connecting=new CyclicBarrier(NUM+1);
        received_all_views=new CyclicBarrier(NUM+1);
        start_disconnecting=new CyclicBarrier(NUM+1);
        disconnected=new CyclicBarrier(NUM+1);

        long start, stop;

        for(int i=0; i < threads.length; i++) {
            threads[i]=new MyThread(i);
View Full Code Here

Examples of EDU.oswego.cs.dl.util.concurrent.CyclicBarrier

        System.out.println("-- [" + Thread.currentThread().getName() + "] " + msg);
    }


    public void testConcurrentStartupAndMerging() throws Exception {
        all_disconnected=new CyclicBarrier(NUM+1);
        start_disconnecting=new CyclicBarrier(NUM+1);

        for(int i=0; i < threads.length; i++) {
            threads[i]=new MyThread(i);
            synchronized(threads[i]) {
                threads[i].start();
View Full Code Here

Examples of edu.emory.mathcs.backport.java.util.concurrent.CyclicBarrier

            }
        }, "Thread Name");
       
        long start = System.currentTimeMillis();
        final int WORKER_COUNT=5;
        final CyclicBarrier barrier = new CyclicBarrier(WORKER_COUNT+1);
        for( int i=0; i< WORKER_COUNT; i++ ) {
            new Thread() {
                public void run() {
                    try {
                        barrier.await();
                        for( int i=0; i < ENQUEUE_COUNT/WORKER_COUNT; i++ ) {
                            queue.incrementAndGet();
                            runner.wakeup();
                            yield();
                        }
                    }
                    catch (BrokenBarrierException e) {
                    }
                    catch (InterruptedException e) {
                    }       
                }
            }.start();
        }
        barrier.await();
       
        boolean b = doneCountDownLatch.await(30, TimeUnit.SECONDS);
        long end = System.currentTimeMillis();
        log.info("Iterations: "+iterations.get());
        log.info("counter: "+counter.get());
View Full Code Here

Examples of java.util.concurrent.CyclicBarrier

        assert map.getMinCredits() == 300;
    }

    public void testBlockingDecrementAndReplenishment() throws Exception {
        final CyclicBarrier barrier=new CyclicBarrier(2);

        Thread thread=new Thread() {
            public void run() {
                try {
                    barrier.await();
                    Util.sleep(1000);
                    replenishAll(100);
                }
                catch(Exception e) {
                    e.printStackTrace();
                }
            }
        };
        thread.start();

        addAll();
        boolean rc=map.decrement(800, 100);
        assert rc;
        System.out.println("map:\n" + map);

        barrier.await();
        rc=map.decrement(250, 5000);
        assert rc;
        System.out.println("map:\n" + map);
        assert map.getMinCredits() == 50;
        assert map.getAccumulatedCredits() == 250;
View Full Code Here

Examples of java.util.concurrent.CyclicBarrier

    */
   public void testReadUncommitted() throws Throwable
   {
      final LockStrategy s = new LockStrategyReadUncommitted();
      final Semaphore sem = new MyFIFOSemaphore(1);
      final CyclicBarrier barrier = new CyclicBarrier(2);

      Thread t1 = new Thread("t1")
      {
         Lock lock = null;

         public void run()
         {
            try
            {
               sem.acquire(); // we're first to the semaphore

               // log("waiting on barrier");
               barrier.await(); // wait until t2 joins us
               // log("passed barrier");
               lock = s.readLock();
               lock.tryLock(TIMEOUT, TimeUnit.MILLISECONDS);
               log("1st read: value is " + value);
               assertEquals(10, value);
               sem.release(); // give t2 time to make the modification
               TestingUtil.sleepThread(100);

               sem.acquire(); // to read the uncommitted modification by t2
               log("2nd read: value is " + value + "; we should see t2's uncommitted change (20)");
               assertEquals(20, value); // we're seeing the modification by t2 before t2 committed (a.k.a. released the lock)
               sem.release();
               TestingUtil.sleepThread(100);

               sem.acquire(); // to read the committed change by t2
               log("3rd read: value is still " + value + "; we should see t2's committed change");
               assertEquals(20, value);
            }
            catch (Throwable ex)
            {
               t1_ex = ex;
            }
            finally
            {
               if (lock != null)
                  lock.unlock();
               sem.release();
            }
         }
      };


      Thread t2 = new Thread("t2")
      {
         Lock lock = null;

         public void run()
         {
            try
            {
               TestingUtil.sleepThread(100);
               barrier.await();
               sem.acquire();
               lock = s.writeLock();
               lock.tryLock(TIMEOUT, TimeUnit.MILLISECONDS);
               log("changing value from " + value + " to 20");
               value = 20;
View Full Code Here

Examples of java.util.concurrent.CyclicBarrier

    static void log(String msg) {
        System.out.println("-- [" + Thread.currentThread().getName() + "] " + msg);
    }

    public void testConcurrentStartupAndMerging() throws Exception {
        start_connecting=new CyclicBarrier(NUM + 1);
        received_all_views=new CyclicBarrier(NUM + 1);
        disconnected=new CyclicBarrier(NUM + 1);

        long start, stop;
        JChannel first=null;

        for(int i=0;i < threads.length;i++) {
View Full Code Here

Examples of java.util.concurrent.CyclicBarrier

        c2.setReceiver(new MyReceiver("C2"));

        final String GROUP=getUniqueClusterName("ConcurrentCloseTest");
        c1.connect(GROUP);
        c2.connect(GROUP);
        CyclicBarrier barrier=new CyclicBarrier(3);

        Closer one=new Closer(c1, barrier), two=new Closer(c2, barrier);
        one.start(); two.start();
        Util.sleep(500);
        barrier.await(); // starts the closing of the 2 channels
        one.join(10000);
        two.join(10000);
        assertFalse(one.isAlive());
        assertFalse(two.isAlive());
    }
View Full Code Here

Examples of java.util.concurrent.CyclicBarrier


    public void testPrioritizedMessages() throws Exception {
        byte[] prios={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};
        PrioSender[] senders=new PrioSender[prios.length];
        final CyclicBarrier barrier=new CyclicBarrier(prios.length +1);
        for(int i=0; i < prios.length; i++) {
            senders[i]=new PrioSender(c1, prios[i], barrier);
            senders[i].start();
        }
        Util.sleep(500);
        barrier.await(); // starts the senders

        for(PrioSender sender: senders)
            sender.join();

        List<Integer> list1=r1.getMsgs(), list2=r2.getMsgs();
View Full Code Here

Examples of java.util.concurrent.CyclicBarrier

        if (size < 1)
            throw new IllegalArgumentException("size < 1");

        this.size = size;

        barrier = new CyclicBarrier(size);
        broadcast = new Broadcast();
        gather = new Gather();
        scatter = new Scatter();
        allGather = new AllGather();
        allToAll = new AllToAll();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.