Hi everyone, I have developed my first COM component (yes, a newbie in the realm of COM development), initialization is done with COINIT_MULTITHREADED
. Also, this COM component is a local server executable. But, I did not add any synchronization code to this component. What do you think: do I have to add CRITICAL_SECTION
s to code or MS COM architecture handles it for me? Thanks in advance.
views:
24answers:
2
A:
Yes.
Use your own mutual exclusion mechanism if you know data is going to be accessed from multiple directions (threads), do not assume MS COM architecture to handle it.
That, at least, what I would have done, based on other technologies Microsoft made which I have experience with - it's like "we make the base, you do the rest". At least with native API.
Wrap the critical section object within a nice class and kick with it!
Poni
2010-10-15 07:37:46
Are there threading models for out-proc servers?
sharptooth
2010-10-15 07:43:24
@sharptooth: No, COM is guaranteed NOT to be thread-safe.
Quandary
2010-10-15 07:55:23