ListenableFuture addListener - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ListenableFuture addListener method.

This code example shows how to use the following methods:addListener
This code example shows how to use the following methods:addListener
This code example shows how to use the following methods:addListener
        } 
    } 
 
    @Override 
    public void addListener(Runnable listener, Executor executor) {
        delegate.addListener(listener, executor);
    } 
 
    @Override 
    public boolean cancel(boolean mayInterruptIfRunning) {
        return delegate.cancel(mayInterruptIfRunning);
    } 
 
    @Override 
    public boolean isCancelled() { 
        return delegate.isCancelled();
    } 
 
    @Override 
    public boolean isDone() { 
4
CodeRank
This code example shows how to use the following methods:addListener
        return future.isCancelled();
    } 
 
    @Override 
    public void addListener(Runnable listener, Executor executor) {
        future.addListener(listener, executor);
    } 
 
    @Override 
    public boolean isDone() { 
        return future.isDone();
    } 
 
    @Override 
    public V get() throws InterruptedException, ExecutionException {
        return future.get();
    } 
 
    @Override 
    public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
4
CodeRank
This code example shows how to use the following methods:addListener
    } 
 
    // implements ListenableFuture<APIResponse> 
 
    public void addListener(Runnable listener, Executor executor) {
        this.apiResponse.addListener(listener, executor);
    } 
 
    // implements Future<APIResponse> 
 
    public boolean cancel(boolean mayInterruptIfRunning) {
        return this.apiResponse.cancel(mayInterruptIfRunning);
    } 
 
    public APIResponse get() throws ExecutionException, InterruptedException {
        return this.apiResponse.get();
    } 
 
    public APIResponse get(long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException {
        return this.apiResponse.get(timeout, unit);
4
CodeRank
This code example shows how to use the following methods:addListener
This code example shows how to use the following methods:addListener
 
  public MockFutureListener(ListenableFuture<?> future) {
    this.countDownLatch = new CountDownLatch(1);
    this.future = future;
 
    future.addListener(this, MoreExecutors.sameThreadExecutor());
  } 
 
  @Override 
  public void run() { 
    countDownLatch.countDown();
  } 
 
  /** 
   * Verify that the listener completes in a reasonable amount of time, and 
   * Asserts that the future returns the expected data. 
   * @throws Throwable if the listener isn't called or if it resulted in a 
   *     throwable or if the result doesn't match the expected value. 
   */ 
  public void assertSuccess(Object expectedData) throws Throwable {
4
CodeRank
This code example shows how to use the following methods:addListener
    public void run() { 
        task.cancel();
    } 
 
    public static void addProgressListener(ListenableFuture<?> future, CommandSender sender, String message) {
        future.addListener(new FutureProgressListener(sender, message), MoreExecutors.sameThreadExecutor());
    } 
 
} 
4
CodeRank
This code example shows how to use the following methods:addListener
        BlockedMonitor oldMonitor = blockedMonitor.getAndSet(monitor);
        if (oldMonitor != null) {
            oldMonitor.run();
        } 
 
        blocked.addListener(monitor, executor);
        // Do not register blocked with driver context.  The driver handles this directly. 
    } 
 
    public void recordFinish() 
    { 
        finishCalls.incrementAndGet();
        finishWallNanos.getAndAdd(nanosBetween(intervalWallStart.get(), System.nanoTime()));
        finishCpuNanos.getAndAdd(nanosBetween(intervalCpuStart.get(), currentThreadCpuTime()));
        finishUserNanos.getAndAdd(nanosBetween(intervalUserStart.get(), currentThreadUserTime()));
    } 
 
    public ListenableFuture<?> isWaitingForMemory()
    { 
        return memoryFuture.get();
4
CodeRank
This code example shows how to use the following methods:isDone, addListener
    } 
 
    ListenableFuture<V> loadAsync(final K key, final int hash,
        final LoadingValueReference<K, V> loadingValueReference, CacheLoader<? super K, V> loader) {
      final ListenableFuture<V> loadingFuture = loadingValueReference.loadFuture(key, loader);
      loadingFuture.addListener(
          new Runnable() {
            @Override 
            public void run() { 
              try { 
                V newValue = getAndRecordStats(key, hash, loadingValueReference, loadingFuture);
              } catch (Throwable t) {
                logger.log(Level.WARNING, "Exception thrown during refresh", t);
                loadingValueReference.setException(t);
              } 
            } 
          }, directExecutor()); 
      return loadingFuture;
    } 
 

0
CodeRank