Using c++11 <thread> with COM threading apartments on Windows – hints, tips, pitfalls?

  apartments, c++, com, multithreading, visual-studio

Am working on a Windows application that uses multiple USB sound interfaces with ASIO drivers. Each driver exposes an in-process COM server and has to be run using a Single Threaded Apartment: My plan is to run each in it’s own STA responsible for processing callbacks and controlling the devices while the heavy lifting is done from a Multiple Threaded Apartment making use of however many hardware threads the processor cores can provide and using whatever the thread and future headers can supply to make the code manageable.

What I am wanting to know is if the standard C++ multi-threading implementations (particularly Visual Studio) play nice with the COM multi-threading requirements (which I’m still researching – marshaling between apartments is still a mystery) or will I get less friction from designing some sort of framework to wrap the appropriate Windows platform API calls?

Source: Windows Questions C++

LEAVE A COMMENT