异步 F# 与 CCR 框架
阅读有关 CCR 的内容后: http://www.infoq.com/news/2008/12 /CCR 我的印象是它的功能与 F# 异步块几乎完全相同?
您产生 port.Receive 和 port.Test 以便执行与“let!”相同的操作。
这是正确的吗? CCR 中是否有 F# 异步无法提供的优势?
After reading about CCR : http://www.infoq.com/news/2008/12/CCR
I get the impression that it does pretty much exactly the same as F# async blocks?
You yield port.Receive and port.Test in order to do the same as "let!".
Is this correct?
And are there any benefits in CCR that you don't get with F# async?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您提到的文章中的示例实际上看起来就像异步工作流程中的
let!
。一般来说,C# 中的yield return
关键字可以对类似于 F# 计算表达式的模式进行编码(以一种奇怪的方式,因为它是为创建枚举器而设计的):我认为 CCR 和 F# 异步工作流程之间的主要区别在于 CCR 还包含用于消息传递并发性的库。例如,请参阅本文 - 它使用
端口 类(您可以向端口发送消息)和
Arbiter.Receive
,这是一个允许您等待来自Port
的消息的原语。在 F# 中,您可以使用
MailboxProcessor
来实现相同的消息传递通信模式,但这不是 F# 异步工作流的内置部分 -MailboxProcessor
是实现的 < em>使用异步工作流程。总结:我认为 F# 异步工作流程更简单,概念更清晰。然而,CCR 和异步工作流程与 MailboxProcessor 一起实现了大致相同的编程模式。
The example in the article you mentioned really looks just like
let!
from asynchronous workflows. In general, theyield return
keyword in C# makes it possible to encode patterns similar to F# computation expressions (in a weird way, because it was designed for creating enumerators):I think that the key difference between CCR and F# asynchronous workflows is that CCR also includes libraries for message-passing concurrency. See for example this article - it uses
Port
class (you can send messages to ports) andArbiter.Receive
, which is a primitive that allows you to wait for messages fromPort
.In F#, you can use
MailboxProcessor
for implementing the same message-passing communication pattern, but this isn't a built-in part of F# asynchronous workflows -MailboxProcessor
is implemented using asynchronous workflows.In summary: I think that F# asynchronous workflows are simpler and conceptually clearer. However, CCR and asynchronous workflows together with
MailboxProcessor
implement roughly the same programming pattern.