I’ve said it before and I’ll say it again: threads don’t scale. But what about Tasks? Here is a simple application which spawns a large (configurable) amount of periodic background tasks: The tasks themselves are technically CPU bound, though they…
Async or non-blocking?
It is often helpful to distinguish between “truly async” code and merely “non-blocking” code. A program that dispatches long running operations to the thread pool would generally be non-blocking since it doesn’t tie up the calling thread. In contrast, a…
Efficient concurrency prevention
Sometimes you want asynchrony but not concurrency. For example, if you are writing data to a file, you should generally prefer asynchronous I/O, but you probably don’t want 10 other competing callers to corrupt the contents. Perhaps the simplest way…
Managed interop for native overlapped
Previously, I shared a basic sample for overlapped I/O with modern C++. I say “basic” but truth be told, there are multiple subtle aspects that one must be keenly aware of to avoid memory leaks or corruption. Thankfully, most of…
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.…
Distributed systems math: availability
Who doesn’t like math? (Rhetorical question, do not answer.) Today we’ll look at some simple math calculations which can help you approximate the overall availability of a distributed system. This model will assume a quorum-based protocol where a simple majority…
Productize or perish
All things being equal, a technology developed for and sold to an external audience is going to be superior to an internal tool fulfilling the same role. After all, the captive marketplace is not known for its ability to produce…
Just for the test of it
Ian Cooper implores you to test behaviors, not implementation details. His video “TDD, where did it all go wrong” expands on these points a bit. The summary is that a bunch of really thorough tests with explicit inner knowledge will…
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.…
Design for disaster: the small stuff
Is your system designed with disaster recovery in mind? There are obvious things like taking backups of state (and maybe validating them, too) and configuring geo-replication to mitigate the effects of regional outages. But what about the more subtle aspects…