我注意到,方法就绪并且
scala.concurrent.Future的结果不能直接调用.当我在REPL中调用它时,我收到错误.因此,我必须调用Await.ready和Await.result.
没关系,但看起来有点尴尬.所以现在我想知道:
>为什么不能直接调用它们;
>在这种情况下,为什么它们作为公共API公开.
解决方法
原因列于
in official doc:
The Future trait implements the Awaitable trait with methods method
ready() and result(). These methods cannot be called directly by the
clients– they can only be called by the execution context.
这样,库设计者强制您在适当的环境中使用这些方法(执行上下文,可能是第三方,或通过Awaitable对象来明确表示阻塞操作).