Last month, I explored some performance optimizations for a C# Letter Boxed solver. It was a fair bit of effort but in the end I could solve a typical puzzle in ~80 ms. Success! However, you might rightly point out…
A simple message bus
The message bus is a typical pattern to allow loosely coupled software components to communicate, usually in an event-driven manner. Don’t let the enterprise-y description deter you — a simple message bus for a single process scenario can be quite…
A real async GetFiles?
I’ve lamented in the past that there is no real async GetFiles. But that’s okay — we’re problem solvers! Perhaps if we could drop down to the core native API, we could fill in a gap like this. Let’s start…
Refactoring C++: Extract Method using `friend struct This`
My day to day programming environment is C# + Visual Studio + ReSharper. I like to think I’m fairly productive in this setup and after years of experience have picked up a few fast and easy ways to refactor my…
The wait is over: coroutines in C++
Long ago, I wrote about using the PPL to achieve a .NET 4.0 level of parity for async programming in C++. Since then, a lot of work has gone into raising this level of parity to .NET 4.5 and beyond.…
DRY RAII with AutoBuffer
Don’t Repeat Yourself is a good maxim in software design — avoid duplication of information. Today’s sample code will show a small fix to a problem which quite literally involves repeating yourself: those annoying “call twice” Win32 functions like GetVirtualDiskPhysicalPath.…
Find bugs for (almost) free
Want to find bugs in your code for (almost) free? Try static code analysis — a useful technique, though often maligned by developers for noise and “false positives”. If you need an appeal to authority to be convinced, see how…
Introducing overlapped I/O
In Windows, I/O operations such as ReadFile can be performed synchronously or asynchronously. Asynchronous I/O is generally referred to as overlapped I/O since multiple operations can be issued at once and “overlap” in their request lifetimes. There are a few…
Avoiding memory leaks: part 2
In the previous post I introduced some of the common cases for avoiding memory leaks with judicious use of unique_ptr. Of course, not all memory management situations are as straightforward, especially when dealing with low-level “C-style” APIs. Let’s explore a…
Avoid memory leaks by design
There are many tools and techniques out there to help detect memory leaks. For instance, you can monitor performance counters for unexpected memory growth. Once a leak is suspected, UMDH might be able to help you pinpoint the culprit. However,…