Synchronizationcontext And Higher Order Functions

It’s often useful to ensure that actions occur on specific threads, in particular event handlers. Take Windows Forms for instance where all operations on a Control must occur on the thread it was created on. Typically this is not a problem since WinForms respond to events such as Click, Move, etc… These events are sourced from the same thread so it’s not an issue.

Factory Methods For Futures

Like most generic classes, I prefer to create Future instances through static factory methods which allows me to take maximum advantage of type inference.

Thread Affinity

Part of creating a multithreading program is understanding which threads objects live on. Seems simple enough and typically is. However it’s nice to insert guarantees to match the design.

Multiple Paths To Iunknown

ATL has a lot of great tools for COM programming and CComPtr is a good example. It’s a smart pointer class which manages the reference count of an underlying COM object.

Building A Future Which Returns No Value

In addition to [Future](/2008/02/13/building-future-t.html) there is also the concept of Futures that don't return any values. Instead the perform the operation and return. Because there is no additional data to pass between the threads building an Empty Future is fairly straight forward.