环境:Akka 2.1,scala 版本 2.10.M6,JDK 1.7,u5
Env: Akka 2.1, scala version 2.10.M6, JDK 1.7,u5
现在是我的问题:我有:
Now is my problem: I have:
future1 = Futures.future(new Callable<Future<object>>(){...}); future2 = ? extends Object; Future.sequence(future1, future2).onComplete(...)现在在第一行,我有一个 Future 对象的 Future,有没有什么办法可以将它转换成 Future 而不阻塞我当前的线程?
now in first line, I have a future of Future of object, is there any way to convert it into a Future while not blocking my current thread?
akka 有什么方法吗?据我检查,我还没有找到任何......第一次发帖....请注意格式错误并组织... :~P
Is there any method in akka? As far as I checked, I havn't found any yet... First time to have a post....Sry for bad format and organize... :~P
推荐答案Short answer (English): flatMap dat sh!t
Short answer (English): flatMap dat sh!t
更短的答案(Scala):
Shorter answer (Scala):
flatMap(identity)最短答案:(Scala 2.12):
Shortest answer: (Scala 2.12):
flatten长答案(Java):
flatMap(new Mapper<Future<X>>,Future<X>>() { @Override public Future<X> apply(final Future<X> f) { return f; } })更多推荐
我怎样才能将未来的未来变成一个未来的对象?
发布评论