在Future
模块的source code,我看到的onComplete
这样的定义:在Scala中,为什么没有`Future.onComplete`的实现?
/** When this future is completed, either through an exception, or a value,
* apply the provided function.
*
* If the future has already been completed,
* this will either be applied immediately or be scheduled asynchronously.
*
* $multipleCallbacks
* $callbackInContext
*/
def onComplete[U](@deprecatedName('func) f: Try[T] => U)(implicit executor: ExecutionContext): Unit
这看起来奇怪,因为它没有函数体(不执行)。那么为什么onComplete
工作?它是用Java实现的吗?我怎样才能找到真正的实现代码?