Seatsar mini-tutorial(2)

6 篇文章 0 订阅
4 篇文章 0 订阅

Future and promise

A future is a result of a computation that may not be available yet. Examples include:

未来是计算的结果,可能尚未可用,例如:

a data buffer that we are reading from the network 我们从网络中读取的数据缓冲区
the expiration of a timer 计时器的期限
the completion of a disk write 完成磁盘写入
the result computation that requires the values from one or more other futures. 需要一个或多个其他期货价值的结果计算
a promise is an object or function that provides you with a future, with the expectation that it will fulfill the future.

一个承诺是一个目标或者功能,它为你提供了一个未来,期望它能够实现未来。

Promises and futures simplify asynchronous programming since they decouple the event producer (the promise) and the event consumer (whoever uses the future). Whether the promise is fulfilled before the future is consumed, or vice versa, does not change the outcome of the code.

允诺和未来简化了异步编程,因为它们将事件生产者(允诺)和事件消费者(使用未来的人)分离开来。 无论承诺是否在未来消耗之前实现,或者反之亦然,都不会改变代码的结果。

Consuming a future

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值