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

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

问题描述:

Here we see a paper by Don Syme on Async state machines in 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#? (and the go command in go-lang)

在这里,我们看到 Don Syme撰写的有关F#中异步状态机的论文。。 我正在努力解决这个问题。 p>

我的问题是-这与C#中的async命令具有相同的作用吗? (以及go-lang中的go命令) p> div>

It's not exactly the same, no, but C# also uses state machines to build the async versions of methods on compilation.

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.

In golang, goroutines are much more similar to the .Net TPL than the async token, conceptually. 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. Go handles the non-blocking I/O for you under the hood.