难道我们还需要Richter的AsyncEnumerator? [英] Do we still need Richter's AsyncEnumerator?

查看:91
本文介绍了难道我们还需要Richter的AsyncEnumerator?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我穿越AsyncEnumerator类形式杰弗里里希特的Power线程库,这似乎解决几个问题的异步编程的东西时,我通常遇到绊倒了。

Recently I stumbled across the AsyncEnumerator class form Jeffrey Richter's Power Threading Library which seems to solve several problems I'm usually encountering when programming asynchronous stuff.

这个类的想法已经有很长一段时间了,我想知道如果.NET / C#当前版本都内置了这种机制的支持现在或者如果它仍然要依靠第三党的图书馆吗?或.NET的,也许新​​版本有一些替代方法,简化异步编程不亚于里希特的AsyncEnumerator呢?

The idea for this class has been around for quite a while now and I'm wondering if current versions of .NET / C# have built-in support for this mechanism by now or if it is still necessary to rely on a third party library? Or maybe newer versions of .NET have some alternative approach which simplifies asynchronous programming as much as Richter's AsyncEnumerator does?

或者换句话说:有没有理由不开始使用Richter的AsyncEnumerator今天

Or in other words: Is there a reason to not start using Richter's AsyncEnumerator today?

编辑:

与AsyncEnumerator一些信息链接:

Some links with information on AsyncEnumerator:

  • Jeffrey Richter and his AsyncEnumerator
  • Simplified APM With The AsyncEnumerator
  • More AsyncEnumerator Features

推荐答案

是的,你仍然会从我的AsyncEnumerator受益。在.NET 4中(任务,并行,PLINQ等)推出了新的线程的东西,是所有关于并发。也就是说,它们都是关于采取的计算工作量,除以它和产卵出来到多个线程,以使工作负荷可在完成更短的时间会比需要1线程来执行整个负载。您可以使用这些结构来同时执行多个同步I / O操作。然而,同步I / O操作引起的所有线程阻塞然后使线程池创建多个线程。所以,你的应用程序的资源使用一飞冲天,而你的CPU使用率仍然很低。这是一个非常低效的结垢实现应用程序和prevents您的应用程序。

Yes, you will still benefit from my AsyncEnumerator. The new threading stuff introduced in .NET 4 (Tasks, Parallel, PLINQ, etc), is all about concurrency. That is, they are all about taking a computational workload, dividing it up and spawning it out onto multiple threads so that the workload can complete in less time than it would takes 1 thread to do the entire workload. You can use these constructs to execute multiple synchronous I/O operations concurrently. However, the synchronous I/O operations cause all the threads to block which then causes the threadpool to create more threads. And so, your app's resource usage skyrockets while your CPU usage remains very low. This is a very inefficient to implement your application and prevents your app from scaling.

我AsyncEnumerator是所有关于启动异步I / O操作,而不会阻塞的线程,使您的应用程序的资源使用情况仍然非常低,因此你的应用尺度非常好。也因为你正在执行I / O,CPU使用率仍然在这种情况下低;不计算工作量。

My AsyncEnumerator is all about initiating asynchronous I/O operations without blocking any threads so that your app's resource usage remains very low so your app scales very well. CPU usage remains low in this case too because you are performing I/O; not a computational workload.

在.NET的下一个版本,新的异步/等待语言功能(我曾与微软),使您能够执行异步I / O而事实上,这些新特性建模非常相似,我AsyncEnumerator。正因如此,你可以端口code使用我AsyncEnumerator的新模式极少数来源$ C ​​$ C的变化。

In the next version of .NET, the new async/await language features (which I worked on with Microsoft), enables you to perform async I/O and in fact, the new features are modeled very similar to my AsyncEnumerator. So much so that you can port code that uses my AsyncEnumerator to the new model with very few source code changes.

至于其他人指出的那样,我AsyncEnumerator仍然提供其他功能,并与.NET 2.0和更高版本的作品。所以,很多人还是会发现它很长一段时间非常有用。

As someone else pointed out, my AsyncEnumerator still offers other features and works with .NET 2.0 and later. So, many people will still find it quite useful for a long time.

这篇关于难道我们还需要Richter的AsyncEnumerator?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆