Joe Duffy's Blog

  • February 9, 2010
  • Extension methods as default interface method implementations
  • One of my comments in the 2nd edition of the .NET Framework design guidelines (on page 164) was that you can use extension methods as a way of getting default implementations for interface methods. We’ve actually begun using these techniques here on my team. To illustrate this trick, let’s rewind the clock and imagine we were designing new collections APIs from day one.

  • January 8, 2010
  • Musing on messages and blocking
  • Sometimes you need to wait for something before proceeding with a computation.

  • January 3, 2010
  • A (brief) retrospective on transactional memory
  • Rewind the clock to mid-2004. Around this time awareness about the looming “concurrency sea change” was rapidly growing industry-wide, and indeed within Microsoft an increasing number of people – myself included – began to focus on how the .NET Framework, CLR, and Visual C++ environments could better accommodate first class concurrent programming. Of course, our colleagues in MSR and researchers in the industry more generally had many years’ head start on us, in some cases dating back 3+decades. It is safe to say that there was no shortage of prior art to understand and learn from.

  • November 1, 2009
  • Lifting T out of Task with dynamic dispatch
  • Say you’ve got a Task<T>. Well, now what?

  • October 31, 2009
  • Tasks and asynchronous control flow
  • Well, Visual Studio 2010 Beta 2 is out on the street. It contains plenty of neat new things to keep one busy for at least a rainy Saturday. I proved this today.

  • October 19, 2009
  • False sharing is no fun
  • Embarrassingly, I neglected to write about the oldest trick in the book in my last post: designing the producer/consumer data structure to reduce false sharing. As I’ve written about several times previously (e.g. see here), and more so in the book, false sharing can be deadly and ought to be avoided.

  • October 4, 2009
  • Fast synchronization between a single producer and single consumer
  • Commonly two threads must communicate with one another, typically to exchange some piece of information. This arises in low-level shared memory synchronization as in PLINQ’s asynchronous data merging, in the implementation of higher level patterns like message passing, inter-process communication, and in countless other situations. If only two agents partake in this arrangement, however, it is possible to implement a highly efficient exchange protocol. Although the situation is rather special, exploiting this opportunity can lead to some interesting performance benefits.

  • July 27, 2009
  • On effects and ubiquitous parallelism
  • I’ve grown convinced over the past few years that taming side effects in our programming languages is a necessary prerequisite to attaining ubiquitous parallelism nirvana. Although I am continuously exploring the ways in which we can accomplish this – ranging from shared nothing isolation, to purely functional programming, and anything and everything in between – what I wonder the most about is whether the development ecosystem at large is ready and willing for such a change.

  • July 13, 2009
  • A simple condition variable primitive
  • In this blog post, I’ll demonstrate building some very simple (but nice!) synchronization abstractions: a Lock type and a standalone ConditionVariable class. And we’ll use a few new types in .NET 4.0 in the process. I had to implement a condition variable recently – the joys of developing a new operating system / platform from the ground up – and decided to put together a toy example for a blog post as I went. Warning: this is for educational purposes only.

  • June 23, 2009
  • Concurrency and exceptions
  • I wrote this memo over 2 1/2 years ago about what to do with concurrent exceptions in Parallel Extensions to .NET. Since Beta1 is now out, I thought posting it may provide some insight into our design decisions. I’ve made only a few slight edits (like replacing code- and type-names), but it’s mainly in original form. I still agree with much of what I wrote, although I’d definitely write it differently today. And in retrospect, I would have driven harder to get deeper runtime integration. Perhaps in the next release.