简体   繁体   English

F#的异步状态机是否与C#的异步或go-lang的go命令相同?

[英]Are F#'s async state machines the same as C#'s async or go-lang's go command?

Here we see a paper by Don Syme on Async state machines in F# . 在这里,我们看到Don Syme撰写的有关F#中的异步状态机的论文 I'm trying to get my head around it. 我正在努力解决这个问题。

My question is - does this do the same thing as the async command in C#? 我的问题是-这与C#中的async命令是否具有相同的作用? (and the go command in go-lang) (以及go-lang中的go命令)

It's not exactly the same, no, but C# also uses state machines to build the async versions of methods on compilation. 并不完全相同,不是,但是C#还使用状态机在编译时构建方法的异步版本。

See http://msdn.microsoft.com/en-us/magazine/hh456403.aspx for a great article by Mads Torgersen about how methods are rewritten in the compiler for C#'s async token. 请参阅http://msdn.microsoft.com/zh-cn/magazine/hh456403.aspx ,以获得Mads Torgersen撰写的精彩文章,内容涉及如何在编译器中针对C#的异步令牌重写方法。

In golang, goroutines are much more similar to the .Net TPL than the async token, conceptually. 在golang中,goroutine在概念上比异步令牌更类似于.Net TPL。 A goroutine is swapped out for another on a thread if it becomes blocking, so you're working with more of a thread pool construct. 如果goroutine变得阻塞,它将在线程上交换为另一个,因此您正在使用更多的线程池构造。 Go handles the non-blocking I/O for you under the hood. Go在后台为您处理非阻塞I / O。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM