In the previous post, I introduced my port of InputQueue to C++. As usual, the unit tests drove the creation of a correct single-threaded implementation but slightly more needed to be done to make the code thread-safe. The go-to construct…
Porting InputQueue to C++
In the previous post, I gave a brief intro to the PPL and the basic constructs for writing async C++ code. In this post, I will discuss the highlights of how I ported the InputQueue sample to C++ using the…
Async in C++ with the PPL
The Parallel Patterns Library (PPL) provides C++ developers with some very useful concurrency primitives along similar lines as Task parallelism in .NET. Having been introduced in Visual Studio 2010, the PPL is not new by any means. However, it remains…
InputQueue use cases
In my previous post, I introduced InputQueue. Now for some (hopefully) realistic examples of how you can use it. Perhaps the most obvious scenario is a command processor with an async dispatch loop, for example: This processor allows a single…
InputQueue, the non-BlockingCollection
The .NET 4.0+ solution to the producer-consumer problem is BlockingCollection. A sample app with a single producer and consumer using an ordered queue of integers would look something like this: This is simple enough, but the problem is that DequeueLoop.…
Better tracing with EventSource
Starting in .NET 4.5, managed code developers finally have a simple way to interact with ETW — System.Diagnostics.Tracing.EventSource. For a quick introduction, check out Vance Morrison’s inaugural blog post on EventSource and the also very helpful feature specification. While EventSource…
Async Process functionality – take 2
In my previous post, I showed a simple way to add a few Task-based async methods for dealing with System.Diagnostics.Process. The code I showed, while simple, has some flaws: It has low cohesion. In violation of the single responsibility principle,…
Providing async functionality for System.Diagnostics.Process
If you need to interact with processes in .NET, you could do worse than System.Diagnostics.Process. But you could also do a bit better, especially since Process provides no out-of-the-box asynchronous methods. But we can fix that! Let’s devise a ProcessEx…
More about asynchronous cleanup
In a previous post, I showed some sample code to implement a UsingAsync method to handle async cleanup. This is a useful pattern but it starts to break down as the number of items to be cleaned up grows beyond…
Threads don’t scale
Async aficionados should know by now that I/O-bound workloads based on dedicated threads simply do not scale past a certain limit. Typically, when you start creating more threads than you have logical CPU cores, you will suffer ever-increasing overhead due…