Examples of tryAcquire()


Examples of java.util.concurrent.Semaphore.tryAcquire()

      }
      {
        // wait until jetty handler receives reply and captures session
        for ( int i = 1; i <= 12; i++ ) {
          log.debug( "Waiting for 5 sec (" + i + ")" );
          if ( semaphore.tryAcquire( 5, TimeUnit.SECONDS ) ) {
            Thread.sleep( 1000 );
            break;
          }
        }
      }

Examples of java.util.concurrent.Semaphore.tryAcquire()

         // Reacquire the semaphore tickets; when we have them all
         // we know the threads are done
         for (int i = 0; i < count; i++)
         {
            boolean acquired = semaphore.tryAcquire(60, TimeUnit.SECONDS);
            if (!acquired) fail("failed to acquire semaphore " + i);
         }

         // allow any async calls to clear
         if (!sync)

Examples of org.apache.hadoop.hbase.InterProcessLock.tryAcquire()

    lock1.acquire();

    //try to acquire, but it will timeout. We are testing whether this will cause any problems
    //due to the read lock being from another client
    InterProcessLock lock2 = clientLock2.writeLock(Bytes.toBytes("client2"));
    assertFalse(lock2.tryAcquire(1000));

    lock1.release();

    //this time it will acquire
    assertTrue(lock2.tryAcquire(5000));

Examples of org.chromium.sdk.CallbackSemaphore.tryAcquire()

    };
    commandSender.sendV8CommandAsync(message, true, callbackWrapper, syncCallback);

    boolean waitRes;
    try {
      waitRes = syncCallback.tryAcquire(timeoutMs, TimeUnit.MILLISECONDS);
    } catch (RuntimeException e) {
      throw new CallbackException(e);
    }

    if (!waitRes) {

Examples of org.menagerie.latches.spi.ZkSemaphore.tryAcquire()

    }

    @Test(timeout = 1000l)
    public void testTryAcquire() throws Exception{
        DistributedSemaphore semaphore = new ZkSemaphore(2,basePath,zkSessionManager);
        assertTrue("Semaphore did not acquire!",semaphore.tryAcquire());
    }

    @Test(timeout = 1000l)
    public void testTryAcquireTimesOut() throws Exception{
        final CountDownLatch latch = new CountDownLatch(1);
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.