我正在尝试使用
scala Futures从网络服务密钥/值存储实现线程批量获取.
大致
import scala.concurrent._ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration._ def bulkGet(keys: List[String]) val listFut = keys.map( future{ "network get request here" } ) val values = Future.sequence(listFut) Await.result(values,Duration(10,SECONDS))
[info] Compiling 1 Scala source to .../target/scala-2.10/classes... [error] .... type mismatch; [error] found : scala.concurrent.Future[List[String]] [error] required: scala.concurrent.Awaitable[scala.concurrent.Future[List[String]]] [error] Await.result(values,SECONDS)) ^
我究竟做错了什么.
我正在关注文档:如何阻止结果
http://docs.scala-lang.org/overviews/core/futures.html
是scala.concurrent.Future不是定义Awaitable?我该如何强迫它?