scala.concurrent.Future.value()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(212)

本文整理了Java中scala.concurrent.Future.value()方法的一些代码示例,展示了Future.value()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.value()方法的具体详情如下:
包路径:scala.concurrent.Future
类名称:Future
方法名:value

Future.value介绍

暂无

代码示例

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

@Override
public T getNow(T valueIfAbsent) throws ExecutionException {
  Preconditions.checkNotNull(scalaFuture);
  Option<Try<T>> value = scalaFuture.value();
  if (value.isDefined()) {
    Try<T> tri = value.get();
    if (tri instanceof Success) {
      return ((Success<T>)tri).value();
    } else {
      throw new ExecutionException(((Failure<T>)tri).exception());
    }
  } else {
    return valueIfAbsent;
  }
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

cachedFuture.value().get().isFailure()) {

代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore

private static ShardBackendInfo createBackendInfo(final Object result, final String shardName, final Long cookie) {
    Preconditions.checkArgument(result instanceof PrimaryShardInfo);
    final PrimaryShardInfo info = (PrimaryShardInfo) result;

    LOG.debug("Creating backend information for {}", info);
    return new ShardBackendInfo(info.getPrimaryShardActor().resolveOne(DEAD_TIMEOUT).value().get().get(),
      toABIVersion(info.getPrimaryShardVersion()), shardName, UnsignedLong.fromLongBits(cookie),
      info.getLocalShardDataTree());
   }
}

代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore

final TransactionContextWrapper newTransactionContextWrapper(final TransactionProxy parent, final String shardName) {
  final TransactionContextWrapper transactionContextWrapper =
      new TransactionContextWrapper(parent.getIdentifier(), actorContext);
  Future<PrimaryShardInfo> findPrimaryFuture = findPrimaryShard(shardName, parent.getIdentifier());
  if(findPrimaryFuture.isCompleted()) {
    Try<PrimaryShardInfo> maybe = findPrimaryFuture.value().get();
    if(maybe.isSuccess()) {
      onFindPrimaryShardSuccess(maybe.get(), parent, shardName, transactionContextWrapper);
    } else {
      onFindPrimaryShardFailure(maybe.failed().get(), parent, shardName, transactionContextWrapper);
    }
  } else {
    findPrimaryFuture.onComplete(new OnComplete<PrimaryShardInfo>() {
      @Override
      public void onComplete(final Throwable failure, final PrimaryShardInfo primaryShardInfo) {
        if (failure == null) {
          onFindPrimaryShardSuccess(primaryShardInfo, parent, shardName, transactionContextWrapper);
        } else {
          onFindPrimaryShardFailure(failure, parent, shardName, transactionContextWrapper);
        }
      }
    }, actorContext.getClientDispatcher());
  }
  return transactionContextWrapper;
}

相关文章