A future is an entity representing the result of an ongoing computation. A synchronisation with a "get" operation blocks the caller until the computation is over, to return the corresponding value. When a computation in charge of fulfilling a future delegates part of its processing to another task, mainstream languages return nested futures, and several "get" operations are needed to retrieve the computed value (we call such futures "control-flow futures"). Several approaches were proposed to tackle this issues: the "forward" construct, that allows the programmer to make delegation explicit and avoid nested futures, and "data-flow explicit futures" which natively collapse nested futures into plain futures. This paper supports the claim that data-flow explicit futures form a powerful set of language primitives, on top of which other approaches can be built. We prove the equivalence, in the context of data-flow explicit futures, between the "forward" construct and classical "return" from functions. The proof relies on a branching bisimulation between a program using "forward" and its "return" counterpart. This result allows language designers to consider "forward" as an optimisation directive rather than as a language primitive. Following the principles of the Godot system, we provide a library implementation of control-flow futures, based on data-flow explicit futures implemented in the compiler. This small library supports the claim that the implementation of classical futures based on data-flow ones is easier than the opposite. Our benchmarks show the viability of the approach from a performance point of view.
翻译:未来是一个代表持续计算结果的实体 。 与“ 获取” 操作同步, 将调用器阻塞到计算完成之前的调用器, 返回相应的值 。 当一个计算负责完成未来代表处理中的一部分任务时, 主流语言返回嵌套的未来, 并且需要几个“ 获取” 操作来检索计算值( 我们称之为“ 控制- 流未来 ” ) 。 为了解决这个问题, 提出了几种方法 : “ 向前” 构造, 使程序设计器能够使授权明确, 避免嵌套未来, 并返回相应的值。 当程序设计器在本地崩溃后, 将“ 嵌入未来未来” 时, 返回相应的“ 明确未来 未来 ” 。 本文支持数据流明确未来 构成一套强大的语言原始 。 在数据流中, “ 前向” 构建一个基于“ 前向” 和“ 向” 后向” 程序, 和“ 后向” 的“ 向” 匹配”, 和“ 后向” 。 这个结果使得语言设计师能够将“ 向未来 方向 用于 未来 未来 的运行,,, 未来 将 将 将 进行 数据流 显示一个基于 的, 的, 以 直流 直流, 向后向,, 向 的 向 向,,, 直流 向,,,, 向 向 向 向 向 向, 向, 向 向 向 向,, 向 向 向 向 向 向 向, 向 向 向 向 向,,,,, 向,,,,,,,,,,,,,,,,,,,,, 向 向,,,,, 向 向,,,,,, 向 向, 向,, 向,,,, 从 向 向,,,