【发布时间】:2023-03-19 04:33:01
【问题描述】:
在Future模块的source code中,我看到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实现的吗?如何找到真正的实现代码?
【问题讨论】:
标签: scala concurrency akka future