Example usage for com.google.common.util.concurrent ListenableFuture isDone

List of usage examples for com.google.common.util.concurrent ListenableFuture isDone

Introduction

In this page you can find the example usage for com.google.common.util.concurrent ListenableFuture isDone.

Prototype

boolean isDone();

Source Link

Document

Returns true if this task completed.

Usage

From source file:io.prestosql.operator.index.PageBufferOperator.java

@Override
public void addInput(Page page) {
    requireNonNull(page, "page is null");
    checkState(blocked == NOT_BLOCKED, "output is already blocked");
    ListenableFuture<?> future = pageBuffer.add(page);
    if (!future.isDone()) {
        this.blocked = future;
    }/*  w w w . j  a v a 2  s. c o  m*/
    operatorContext.recordOutput(page.getSizeInBytes(), page.getPositionCount());
}

From source file:com.facebook.presto.operator.index.PageBufferOperator.java

@Override
public void addInput(Page page) {
    requireNonNull(page, "page is null");
    checkState(blocked == NOT_BLOCKED, "output is already blocked");
    ListenableFuture<?> future = pageBuffer.add(page);
    if (!future.isDone()) {
        this.blocked = future;
    }//from w  w w  .  j  ava 2  s. c  o  m
    operatorContext.recordGeneratedOutput(page.getSizeInBytes(), page.getPositionCount());
}

From source file:dagger.producers.internal.DependencyMethodProducer.java

@Override
public final ListenableFuture<T> get() {
    synchronized (futures) {
        if (cancelled) {
            return Futures.immediateCancelledFuture();
        }//from   ww w.  java 2  s . c  om

        final ListenableFuture<T> future = callDependencyMethod();
        if (!future.isDone() && futures.add(future)) {
            future.addListener(new Runnable() {
                @Override
                public void run() {
                    synchronized (futures) {
                        futures.remove(future);
                    }
                }
            }, directExecutor());
        }
        return future;
    }
}

From source file:com.facebook.presto.operator.TaskOutputOperator.java

@Override
public void addInput(Page page) {
    requireNonNull(page, "page is null");
    checkState(blocked == NOT_BLOCKED, "output is already blocked");
    ListenableFuture<?> future = sharedBuffer.enqueue(page);
    if (!future.isDone()) {
        this.blocked = future;
    }//from  w ww . ja va  2s . co  m
    operatorContext.recordGeneratedOutput(page.getSizeInBytes(), page.getPositionCount());
}

From source file:io.prestosql.operator.TaskOutputOperator.java

@Override
public ListenableFuture<?> isBlocked() {
    ListenableFuture<?> blocked = outputBuffer.isFull();
    return blocked.isDone() ? NOT_BLOCKED : blocked;
}

From source file:com.facebook.presto.operator.InMemoryExchangeSourceOperator.java

@Override
public ListenableFuture<?> isBlocked() {
    ListenableFuture<?> blocked = exchange.waitForReading(bufferIndex);
    if (blocked.isDone()) {
        return NOT_BLOCKED;
    }/*from  w  w w  . j a v  a 2s.co  m*/
    return blocked;
}

From source file:dagger.producers.internal.DependencyMethodProducer.java

@Override
public final Producer<T> newEntryPointView(final CancellationListener cancellationListener) {
    return new Producer<T>() {
        private final Set<ListenableFuture<T>> entryPointFutures = Collections
                .newSetFromMap(new MapMaker().weakKeys().<ListenableFuture<T>, Boolean>makeMap());

        @Override//from w  ww  .java  2 s.c  o m
        public ListenableFuture<T> get() {
            final ListenableFuture<T> future = DependencyMethodProducer.this.get();
            if (!future.isDone() && entryPointFutures.add(future)) {
                future.addListener(new Runnable() {
                    @Override
                    public void run() {
                        entryPointFutures.remove(future);
                        if (future.isCancelled()) {
                            // TODO(cgdecker): Make this also propagate the actual value that was passed for
                            // mayInterruptIfRunning
                            cancellationListener.onProducerFutureCancelled(true);
                        }
                    }
                }, directExecutor());
            }
            return future;
        }
    };
}

From source file:io.prestosql.operator.ExchangeOperator.java

@Override
public ListenableFuture<?> isBlocked() {
    ListenableFuture<?> blocked = exchangeClient.isBlocked();
    if (blocked.isDone()) {
        return NOT_BLOCKED;
    }/* ww  w .  j a  v  a 2  s . com*/
    return blocked;
}

From source file:com.google.vertcoin.examples.ExamplePaymentChannelClient.java

private void waitForSufficientBalance(BigInteger amount) {
    // Not enough money in the wallet.
    BigInteger amountPlusFee = amount.add(Wallet.SendRequest.DEFAULT_FEE_PER_KB);
    // ESTIMATED because we don't really need to wait for confirmation.
    ListenableFuture<BigInteger> balanceFuture = appKit.wallet().getBalanceFuture(amountPlusFee,
            Wallet.BalanceType.ESTIMATED);
    if (!balanceFuture.isDone()) {
        System.out.println("Please send " + Utils.bitcoinValueToFriendlyString(amountPlusFee) + " BTC to "
                + myKey.toAddress(params));
        Futures.getUnchecked(balanceFuture);
    }//from w  ww  .j a v  a  2 s . c o m
}

From source file:com.tribesman.kobocoinj.examples.ExamplePaymentChannelClient.java

private void waitForSufficientBalance(BigInteger amount) {
    // Not enough money in the wallet.
    BigInteger amountPlusFee = amount.add(Wallet.SendRequest.DEFAULT_FEE_PER_KB);
    // ESTIMATED because we don't really need to wait for confirmation.
    ListenableFuture<BigInteger> balanceFuture = appKit.wallet().getBalanceFuture(amountPlusFee,
            Wallet.BalanceType.ESTIMATED);
    if (!balanceFuture.isDone()) {
        System.out.println("Please send " + Utils.kobocoinValueToFriendlyString(amountPlusFee) + " BTC to "
                + myKey.toAddress(params));
        Futures.getUnchecked(balanceFuture);
    }/* ww w .ja  v  a  2 s .  c  o m*/
}