Codota Logo
com.google.common.util.concurrent
Code IndexAdd Codota to your IDE (free)

How to use com.google.common.util.concurrent

Best Java code snippets using com.google.common.util.concurrent (Showing top 20 results out of 6,867)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
origin: google/guava

public void testCatching_resultCancelledBeforeFallback() throws Exception {
 SettableFuture<Integer> primary = SettableFuture.create();
 Function<Throwable, Integer> fallback = unexpectedFunction();
 ListenableFuture<Integer> derived =
   catching(primary, Throwable.class, fallback, directExecutor());
 derived.cancel(false);
 assertTrue(primary.isCancelled());
 assertFalse(primary.wasInterrupted());
}
origin: google/guava

public void testExecutorSuccess() {
 CountingSameThreadExecutor ex = new CountingSameThreadExecutor();
 SettableFuture<String> f = SettableFuture.create();
 MockCallback callback = new MockCallback("foo");
 Futures.addCallback(f, callback, ex);
 f.set("foo");
 assertEquals(1, ex.runCount);
}
origin: google/guava

public void testCatchingAsync_resultCancelledBeforeFallback() throws Exception {
 SettableFuture<Integer> primary = SettableFuture.create();
 AsyncFunction<Throwable, Integer> fallback = unexpectedAsyncFunction();
 ListenableFuture<Integer> derived =
   catchingAsync(primary, Throwable.class, fallback, directExecutor());
 derived.cancel(false);
 assertTrue(primary.isCancelled());
 assertFalse(primary.wasInterrupted());
}
origin: google/guava

public void testAllAsList_resultCancelled() throws Exception {
 SettableFuture<String> future1 = SettableFuture.create();
 SettableFuture<String> future2 = SettableFuture.create();
 @SuppressWarnings("unchecked") // array is never modified
 ListenableFuture<List<String>> compound = allAsList(future1, future2);
 future2.set(DATA2);
 assertFalse(compound.isDone());
 assertTrue(compound.cancel(false));
 assertTrue(compound.isCancelled());
 assertTrue(future1.isCancelled());
 assertFalse(future1.wasInterrupted());
}
origin: google/guava

public void testSameThreadSuccess() {
 SettableFuture<String> f = SettableFuture.create();
 MockCallback callback = new MockCallback("foo");
 addCallback(f, callback, directExecutor());
 f.set("foo");
}
origin: google/guava

public void testNonCancellationPropagating_successful() throws Exception {
 SettableFuture<Foo> input = SettableFuture.create();
 ListenableFuture<Foo> wrapper = nonCancellationPropagating(input);
 Foo foo = new Foo();
 assertFalse(wrapper.isDone());
 input.set(foo);
 assertTrue(wrapper.isDone());
 assertSame(foo, getDone(wrapper));
}
origin: google/guava

public void testNonCancellationPropagating_doesNotPropagate() throws Exception {
 SettableFuture<Foo> input = SettableFuture.create();
 ListenableFuture<Foo> wrapper = nonCancellationPropagating(input);
 assertTrue(wrapper.cancel(true));
 assertTrue(wrapper.isCancelled());
 assertTrue(wrapper.isDone());
 assertFalse(input.isCancelled());
 assertFalse(input.isDone());
}
origin: google/guava

public void testAllAsList_resultCancelled_withSecondaryListFuture() throws Exception {
 SettableFuture<String> future1 = SettableFuture.create();
 SettableFuture<String> future2 = SettableFuture.create();
 ListenableFuture<List<String>> compound = allAsList(future1, future2);
 // This next call is "unused," but it is an important part of the test. Don't remove it!
 ListenableFuture<List<String>> unused = allAsList(future1, future2);
 assertTrue(compound.cancel(false));
 assertTrue(future1.isCancelled());
 assertFalse(future1.wasInterrupted());
 assertTrue(future2.isCancelled());
 assertFalse(future2.wasInterrupted());
}
origin: google/guava

public void testNonCancellationPropagating_delegateCancelled() throws Exception {
 SettableFuture<Foo> input = SettableFuture.create();
 ListenableFuture<Foo> wrapper = nonCancellationPropagating(input);
 assertFalse(wrapper.isDone());
 assertTrue(input.cancel(false));
 assertTrue(wrapper.isCancelled());
}
origin: google/guava

private static void assertListenerRunImmediately(ListenableFuture<?> future) {
 CountingRunnable listener = new CountingRunnable();
 future.addListener(listener, directExecutor());
 assertEquals(1, listener.count);
}
origin: google/guava

public void testServiceStartStop() throws Exception {
 AbstractIdleService service = new DefaultService();
 service.startAsync().awaitRunning();
 assertEquals(Service.State.RUNNING, service.state());
 service.stopAsync().awaitTerminated();
 assertEquals(Service.State.TERMINATED, service.state());
}
origin: google/guava

public void testServiceToString() {
 AbstractIdleService service = new TestService();
 assertEquals("TestService [NEW]", service.toString());
 service.startAsync().awaitRunning();
 assertEquals("TestService [RUNNING]", service.toString());
 service.stopAsync().awaitTerminated();
 assertEquals("TestService [TERMINATED]", service.toString());
}
origin: google/guava

public final void testWaitFor_initiallyFalse() throws Exception {
 TestGuard guard = new TestGuard(false);
 thread1.callAndAssertReturns(enter());
 thread1.callAndAssertWaits(waitFor(), guard);
 monitor.enter();
 guard.setSatisfied(true);
 monitor.leave();
 thread1.assertPriorCallReturns(waitFor());
}
origin: google/guava

public final void testEnterWhen_initiallyFalse() throws Exception {
 TestGuard guard = new TestGuard(false);
 thread1.callAndAssertWaits(enterWhen(), guard);
 monitor.enter();
 guard.setSatisfied(true);
 monitor.leave();
 thread1.assertPriorCallReturns(enterWhen());
}
origin: google/guava

public final void testEnterWhen_initiallyTrue() throws Exception {
 TestGuard guard = new TestGuard(true);
 thread1.callAndAssertReturns(enterWhen(), guard);
 // same as above but with the new syntax
 thread1.callAndAssertReturns(enterWhen(), monitor.newGuard(() -> true));
}
origin: google/guava

public void testSuccessfulAsList_resultInterrupted() throws Exception {
 SettableFuture<String> future1 = SettableFuture.create();
 SettableFuture<String> future2 = SettableFuture.create();
 @SuppressWarnings("unchecked") // array is never modified
 ListenableFuture<List<String>> compound = successfulAsList(future1, future2);
 future2.set(DATA2);
 assertFalse(compound.isDone());
 assertTrue(compound.cancel(true));
 assertTrue(compound.isCancelled());
 assertTrue(future1.isCancelled());
 assertTrue(future1.wasInterrupted());
}
origin: google/guava

public void testCatchingAsync_resultInterruptedBeforeFallback() throws Exception {
 SettableFuture<Integer> primary = SettableFuture.create();
 AsyncFunction<Throwable, Integer> fallback = unexpectedAsyncFunction();
 ListenableFuture<Integer> derived =
   catchingAsync(primary, Throwable.class, fallback, directExecutor());
 derived.cancel(true);
 assertTrue(primary.isCancelled());
 assertTrue(primary.wasInterrupted());
}
origin: google/guava

public void testCatching_resultInterruptedBeforeFallback() throws Exception {
 SettableFuture<Integer> primary = SettableFuture.create();
 Function<Throwable, Integer> fallback = unexpectedFunction();
 ListenableFuture<Integer> derived =
   catching(primary, Throwable.class, fallback, directExecutor());
 derived.cancel(true);
 assertTrue(primary.isCancelled());
 assertTrue(primary.wasInterrupted());
}
origin: google/guava

public void testSuccessfulAsList_resultCancelled() throws Exception {
 SettableFuture<String> future1 = SettableFuture.create();
 SettableFuture<String> future2 = SettableFuture.create();
 @SuppressWarnings("unchecked") // array is never modified
 ListenableFuture<List<String>> compound = successfulAsList(future1, future2);
 future2.set(DATA2);
 assertFalse(compound.isDone());
 assertTrue(compound.cancel(false));
 assertTrue(compound.isCancelled());
 assertTrue(future1.isCancelled());
 assertFalse(future1.wasInterrupted());
}
origin: google/guava

public void testAllAsList_resultInterrupted() throws Exception {
 SettableFuture<String> future1 = SettableFuture.create();
 SettableFuture<String> future2 = SettableFuture.create();
 @SuppressWarnings("unchecked") // array is never modified
 ListenableFuture<List<String>> compound = allAsList(future1, future2);
 future2.set(DATA2);
 assertFalse(compound.isDone());
 assertTrue(compound.cancel(true));
 assertTrue(compound.isCancelled());
 assertTrue(future1.isCancelled());
 assertTrue(future1.wasInterrupted());
}
com.google.common.util.concurrent

Most used classes

  • Futures
    Static utility methods pertaining to the Future interface.Many of these methods use the ListenableFu
  • ThreadFactoryBuilder
    A ThreadFactory builder, providing any combination of these features: * whether threads should be
  • MoreExecutors
  • ListenableFuture
  • ListeningExecutorService
    An ExecutorService that returns ListenableFuture instances. To create an instance from an existing E
  • Uninterruptibles,
  • UncheckedExecutionException,
  • RateLimiter,
  • CheckedFuture,
  • Service,
  • AtomicDouble,
  • AbstractFuture,
  • ListeningScheduledExecutorService,
  • ListenableFutureTask,
  • Atomics,
  • AbstractScheduledService$Scheduler,
  • FutureCallback,
  • SimpleTimeLimiter,
  • ServiceManager
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now