COM Multi-threaded architecture on multi core machine
How does COM ensure that on a multi-core machine, it stays in Sync if you have a COM out-of-proc server and a COM client, relying on each other, that things don't get mangled if you're running it on a multi-c开发者_Python百科ore architecture?
In your comment you ask what happens if COM client runs on one thread and COM server - on another thread. Those two threads reside in different processes (since the server is out-proc).
If your client consumes an out-proc COM server COM subsystem uses RPC (local RPC) for communicating with the server. This is done transparently for the client - the client calls a method, RPC prepares a string with all the parameters, blocks the client thread, passes the call to the server, the server processes the call abd returns to the client. There's no concurrent access, so no problems with extra synchronization - all the synchronization is done automatically.
As your COM server is out-of-proc, the threads for client and server are running in separate processes. The inter-process synchronization mechanisms in Windows work across cores or processors, so the COM subsystem will already be handling any multi-core/processor issues for you.
If you've got data that may change on the Server end without the Client knowing, that's a problem for single-CPU/core too - you need to address this either with polling (bad) or client notification interface (better).
精彩评论