本文整理汇总了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());
}
示例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);
}
示例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);
}
示例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);
}