是在编译器严格执行新的C#异步功能是在、编译器、严格执行、功能

由网友(聚散不由你我)分享简介:作为一个C#程序员的兴趣探索,我非常想了解多一点的过程,使新的异步的功能的工作。As a C# programmer whose interested in exploring "how things work", i am interested in understanding a bit more about t...

作为一个C#程序员的兴趣探索,我非常想了解多一点的过程,使新的异步的功能的工作。

As a C# programmer whose interested in exploring "how things work", i am interested in understanding a bit more about the process that makes the new async feature work.

我跟埃里克利珀的优秀文章系列异步:异步的博客文章

I have followed Eric Lippert's excellent article series on async: Async blog posts

我不记得看​​到任何地方提到这个功能的实现(高电平)除了在为我们编译器正在做的大部分工作的事实。

I don't remember seeing anywhere any reference to the implementation of this feature (in a high level) except for the fact the the "compiler is doing most of the work" for us.

时此功能严格意义上的编译器的功能呢?该编译器重写code以某种方式,这就是它?还是有其他的事情一样运行库支持,使这种情况发生?

Is this feature strictly a compiler feature then? does the compiler rewrite the code in some manner and that's it? or are there other things like runtime support that make this happen?

推荐答案

没有,不是的完全的编译器。它依赖于一些新的接口,如INotifyCompletion有的框架的执行的支持,如AsyncTaskMethodBuilder.我不相信有,虽然所需要的任何CLR的变化。

No, it's not entirely in the compiler. It relies on some new interfaces such as INotifyCompletion and some framework implementation support such as AsyncTaskMethodBuilder. I don't believe there are any CLR changes required though.

编译器做了很多工作,构建国家机器 - 它只是指一些这些类型的状态机内。哦,还有很多工作 - 相关类型的人显著主要是出于性能方面的修改。

The compiler does a lot of work, building a state machine - it just refers to a few of those types within the state machine. Oh, and a lot of the Task-related types were significantly modified primarily for performance reasons.

我有一个一系列博客文章它最初写对CTP,但的只有的使用香草.NET 4和一些类我刮起了自己。他们不会对生产实施工作(如事情改变了一点随着时间的推移),但他们会给你这是怎么回事幕后一般IM pression。

I have a series of blog posts which were initially written against the CTP but only using vanilla .NET 4 and some classes I whipped up myself. They won't work against the production implementation (as things changed a bit over time) but they'll give you a general impression of what's going on behind the scenes.

阅读全文

相关推荐

最新文章