当前位置: 首页>>代码示例>>Java>>正文


Java Future.map方法代码示例

本文整理汇总了Java中scala.concurrent.Future.map方法的典型用法代码示例。如果您正苦于以下问题:Java Future.map方法的具体用法?Java Future.map怎么用?Java Future.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scala.concurrent.Future的用法示例。


在下文中一共展示了Future.map方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findLocalShardAsync

import scala.concurrent.Future; //导入方法依赖的package包/类
/**
 * Finds a local shard async given its shard name and return a Future from which to obtain the
 * ActorRef.
 *
 * @param shardName the name of the local shard that needs to be found
 */
public Future<ActorRef> findLocalShardAsync(final String shardName) {
    Future<Object> future = executeOperationAsync(shardManager,
            new FindLocalShard(shardName, true), shardInitializationTimeout);

    return future.map(new Mapper<Object, ActorRef>() {
        @Override
        public ActorRef checkedApply(Object response) throws Throwable {
            if (response instanceof LocalShardFound) {
                LocalShardFound found = (LocalShardFound)response;
                LOG.debug("Local shard found {}", found.getPath());
                return found.getPath();
            } else if (response instanceof NotInitializedException) {
                throw (NotInitializedException)response;
            } else if (response instanceof LocalShardNotFound) {
                throw new LocalShardNotFoundException(
                        String.format("Local shard for %s does not exist.", shardName));
            }

            throw new UnknownMessageException(String.format(
                    "FindLocalShard returned unkown response: %s", response));
        }
    }, getClientDispatcher());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:30,代码来源:ActorContext.java

示例2: mapConstN

import scala.concurrent.Future; //导入方法依赖的package包/类
@Benchmark
public String mapConstN() throws Exception {
  Future<String> f = constFuture;
  for (int i = 0; i < N.n; i++)
    f = f.map(mapF, ec);
  return Await.result(f, inf);
}
 
开发者ID:traneio,项目名称:future,代码行数:8,代码来源:ScalaFutureBenchmark.java

示例3: mapPromiseN

import scala.concurrent.Future; //导入方法依赖的package包/类
@Benchmark
public String mapPromiseN() throws Exception {
  Promise<String> p = Promise.<String>apply();
  Future<String> f = p.future();
  for (int i = 0; i < N.n; i++)
    f = f.map(mapF, ec);
  p.success(string);
  return Await.result(f, inf);
}
 
开发者ID:traneio,项目名称:future,代码行数:10,代码来源:ScalaFutureBenchmark.java

示例4: setValueN

import scala.concurrent.Future; //导入方法依赖的package包/类
@Benchmark
public String setValueN() throws Exception {
  Promise<String> p = Promise.<String>apply();
  Future<String> f = p.future();
  for (int i = 0; i < N.n; i++)
    f = f.map(mapF, ec);
  p.success(string);
  return Await.result(f, inf);
}
 
开发者ID:traneio,项目名称:future,代码行数:10,代码来源:ScalaFutureBenchmark.java


注:本文中的scala.concurrent.Future.map方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。