MTA COM with STA data member 
Author Message
 MTA COM with STA data member

Hi

I have a MTA COM EXE component, whose coclass has
as data members, a STA COM EXE component, and a
MTA COM DLL component.

Basically, client applications call into the MTA
EXE component, and those calls are then forwarded
to the STA EXE or MTA DLL component.

I'm new to COM, and I am still trying to
understand the threading issues with COM.  In the
above scenario, is it necessary to protect the
two data members (as critical sections) with
semaphores?

Thank You in Advance.

Sent via Deja.com
http://www.*-*-*.com/



Thu, 17 Jul 2003 16:38:37 GMT  
 MTA COM with STA data member
Hi

I have a question about the following scenario.

I have a MTA COM EXE component.  This coclass has, as two private data
members a STA COM EXE, and a MTA COM DLL.  My client applications
communicate with the MTA EXE component, and there requests are
forwarded to either of the two other components.

Sorry, I'm new to COM, and still don't have a great understanding of
the threading issues with COM.  In my above scenario, would I have to
protect the calls to the above two member components (as critical
sections)?  Or does COM internally deal with that, since these data
members are other COM components?

Thanks in Advance

Sent via Deja.com
http://www.deja.com/



Thu, 17 Jul 2003 16:44:04 GMT  
 MTA COM with STA data member
You don't have to protect the _calls_. COM will (or will not) take care
of that, but you need not take care altogether. Specifically, COM will
serialize the calls to the single-threaded out-of-proc EXE server.
This happens in that server's process - not yours. The calls to the
free-threaded in-proc DLL server are not serialized altoghether
because both the client (your MTA server) and the server (the DLL)
use the MTA model. Maximum performance and no syncronization.
The DLL itself is responsible for guarding access to any internal
variables it may have.

However, you may have to protect if you change these interface
pointers in the normal cource of the work of your MTA server.
If you only create them during the initialization of your object,
you don't need to protect them at all - read-only access. The
problem is the ATL's CCom[QI]Ptr smart pointers are not
thread-safe. If you change the pointers at any time during
the normal work of the MTA server, your best strategy is to
write your own thread-safe smart pointers and use them
instead.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:

> Hi

> I have a question about the following scenario.

> I have a MTA COM EXE component.  This coclass has, as two private data
> members a STA COM EXE, and a MTA COM DLL.  My client applications
> communicate with the MTA EXE component, and there requests are
> forwarded to either of the two other components.

> Sorry, I'm new to COM, and still don't have a great understanding of
> the threading issues with COM.  In my above scenario, would I have to
> protect the calls to the above two member components (as critical
> sections)?  Or does COM internally deal with that, since these data
> members are other COM components?

> Thanks in Advance

> Sent via Deja.com
> http://www.deja.com/



Sat, 19 Jul 2003 04:19:44 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Callback Handling mechanisms in STA client when fired from MTA atl com server

2. STA VB exe calling ATL MTA component loses ErrorInfo

3. STA - MTA & In process marshaling

4. STA, MTA

5. MTA/STA Events in VB

6. converting a STA project to a MTA

7. MTA <-> STA interaction problem with threads

8. Marshaling an interface from an STA to MTA

9. Difference between MTA and STA question

10. MTA-STA

11. SendMessage STA, MTA

12. STA and MTA in the same application

 

 
Powered by phpBB® Forum Software