/** * Invokes {@code semaphore.}{@link Semaphore#tryAcquire(int, long, TimeUnit) tryAcquire(1, * timeout, unit)} uninterruptibly. * * @since 18.0 */ @GwtIncompatible // concurrency @SuppressWarnings("GoodTime") // should accept a java.time.Duration public static boolean tryAcquireUninterruptibly( Semaphore semaphore, long timeout, TimeUnit unit) { return tryAcquireUninterruptibly(semaphore, 1, timeout, unit); }
/** * Invokes {@code semaphore.}{@link Semaphore#tryAcquire(int, long, TimeUnit) tryAcquire(1, * timeout, unit)} uninterruptibly. * * @since 18.0 */ @GwtIncompatible // concurrency public static boolean tryAcquireUninterruptibly( Semaphore semaphore, long timeout, TimeUnit unit) { return tryAcquireUninterruptibly(semaphore, 1, timeout, unit); }
/** * Invokes {@code semaphore.}{@link Semaphore#tryAcquire(int, long, TimeUnit) tryAcquire(1, * timeout, unit)} uninterruptibly. * * @since 18.0 */ @GwtIncompatible // concurrency public static boolean tryAcquireUninterruptibly( Semaphore semaphore, long timeout, TimeUnit unit) { return tryAcquireUninterruptibly(semaphore, 1, timeout, unit); }
/** * Requests a permit from the semaphore with a timeout and asserts that operation completed in * the expected timeframe. */ void tryAcquireSuccessfully(long timeoutMillis) { assertTrue(tryAcquireUninterruptibly(semaphore, timeoutMillis, MILLISECONDS)); completed.assertCompletionExpected(); }
void tryAcquireSuccessfully(int permits, long timeoutMillis) { assertTrue(tryAcquireUninterruptibly(semaphore, permits, timeoutMillis, MILLISECONDS)); completed.assertCompletionExpected(); }
public void testTryAcquireWithNoWait() { Stopwatch stopwatch = Stopwatch.createStarted(); Semaphore semaphore = new Semaphore(99); assertTrue(tryAcquireUninterruptibly(semaphore, 0, MILLISECONDS)); assertTrue(tryAcquireUninterruptibly(semaphore, -42, MILLISECONDS)); assertTrue(tryAcquireUninterruptibly(semaphore, LONG_DELAY_MS, MILLISECONDS)); assertTimeNotPassed(stopwatch, LONG_DELAY_MS); }
public void testTryAcquireWithNoWaitMultiPermit() { Stopwatch stopwatch = Stopwatch.createStarted(); Semaphore semaphore = new Semaphore(99); assertTrue(tryAcquireUninterruptibly(semaphore, 10, 0, MILLISECONDS)); assertTrue(tryAcquireUninterruptibly(semaphore, 10, -42, MILLISECONDS)); assertTrue(tryAcquireUninterruptibly(semaphore, 10, LONG_DELAY_MS, MILLISECONDS)); assertTimeNotPassed(stopwatch, LONG_DELAY_MS); }
/** * Requests a permit from the semaphore with a timeout and asserts that the wait returned within * the expected timeout. */ private void tryAcquireUnsuccessfully(long timeoutMillis) { assertFalse(tryAcquireUninterruptibly(semaphore, timeoutMillis, MILLISECONDS)); completed.assertCompletionNotExpected(timeoutMillis); }
private void tryAcquireUnsuccessfully(int permits, long timeoutMillis) { assertFalse(tryAcquireUninterruptibly(semaphore, permits, timeoutMillis, MILLISECONDS)); completed.assertCompletionNotExpected(timeoutMillis); }
/** * Invokes {@code semaphore.}{@link Semaphore#tryAcquire(int, long, TimeUnit) tryAcquire(1, * timeout, unit)} uninterruptibly. * * @since 18.0 */ @GwtIncompatible // concurrency public static boolean tryAcquireUninterruptibly( Semaphore semaphore, long timeout, TimeUnit unit) { return tryAcquireUninterruptibly(semaphore, 1, timeout, unit); }
/** * Invokes {@code semaphore.}{@link Semaphore#tryAcquire(int, long, TimeUnit) * tryAcquire(1, timeout, unit)} uninterruptibly. * * @since 18.0 */ @GwtIncompatible("concurrency") public static boolean tryAcquireUninterruptibly( Semaphore semaphore, long timeout, TimeUnit unit) { return tryAcquireUninterruptibly(semaphore, 1, timeout, unit); }
/** * Invokes {@code semaphore.}{@link Semaphore#tryAcquire(int, long, TimeUnit) tryAcquire(1, * timeout, unit)} uninterruptibly. * * @since 18.0 */ @GwtIncompatible // concurrency public static boolean tryAcquireUninterruptibly( Semaphore semaphore, long timeout, TimeUnit unit) { return tryAcquireUninterruptibly(semaphore, 1, timeout, unit); }
/** * Requests a permit from the semaphore with a timeout and asserts that operation completed in * the expected timeframe. */ void tryAcquireSuccessfully(long timeoutMillis) { assertTrue(tryAcquireUninterruptibly(semaphore, timeoutMillis, MILLISECONDS)); completed.assertCompletionExpected(); }
void tryAcquireSuccessfully(int permits, long timeoutMillis) { assertTrue(tryAcquireUninterruptibly(semaphore, permits, timeoutMillis, MILLISECONDS)); completed.assertCompletionExpected(); }
public void testTryAcquireWithNoWait() { Stopwatch stopwatch = Stopwatch.createStarted(); Semaphore semaphore = new Semaphore(99); assertTrue(tryAcquireUninterruptibly(semaphore, 0, MILLISECONDS)); assertTrue(tryAcquireUninterruptibly(semaphore, -42, MILLISECONDS)); assertTrue(tryAcquireUninterruptibly(semaphore, LONG_DELAY_MS, MILLISECONDS)); assertTimeNotPassed(stopwatch, LONG_DELAY_MS); }
public void testTryAcquireWithNoWaitMultiPermit() { Stopwatch stopwatch = Stopwatch.createStarted(); Semaphore semaphore = new Semaphore(99); assertTrue(tryAcquireUninterruptibly(semaphore, 10, 0, MILLISECONDS)); assertTrue(tryAcquireUninterruptibly(semaphore, 10, -42, MILLISECONDS)); assertTrue(tryAcquireUninterruptibly(semaphore, 10, LONG_DELAY_MS, MILLISECONDS)); assertTimeNotPassed(stopwatch, LONG_DELAY_MS); }
/** * Requests a permit from the semaphore with a timeout and asserts that the wait returned * within the expected timeout. */ private void tryAcquireUnsuccessfully(long timeoutMillis) { assertFalse(tryAcquireUninterruptibly(semaphore, timeoutMillis, MILLISECONDS)); completed.assertCompletionNotExpected(timeoutMillis); }
private void tryAcquireUnsuccessfully(int permits, long timeoutMillis) { assertFalse(tryAcquireUninterruptibly(semaphore, permits, timeoutMillis, MILLISECONDS)); completed.assertCompletionNotExpected(timeoutMillis); }