That is a question a co-worker of mine asked. I did remember that I used to know what it does mean, but earlier today when I came back home, I have double checked in my COM reference book and I have found a subsection dedicated to the subject.
COM deals with multithreading by defining an apartment concept. 2 Apartment types exist: The single threaded apartment (STA) and the Multi-threaded apartment (MTA). One of the numerous COM class attributes is in which apartment type objects of that class are allowed to run. 3 values are possible for that attribute: STA, MTA or both.
When a thread wants to access a STA object, it will go through the same process than if the object was remote and will go through a proxy object, marshalling/unmarshalling and the thread residing in the remote STA apartment which must have a message loop, will receive the request. This whole process adds a lot of overhead and for that reason, COM allows to create a custom marshaller. Your COM object would have to implement the interface IMarshal. One example of a custom marshaller would be to serialize the whole object state to create an exact copy of it on the proxy side so once unmarshalled, all access to it would remain local.
Now, (I know the short explanation is starting to be long), in the case that a developer went through the process of making his COM class thread safe to support MTA, it would be a good idea to have a custom marshaller to just serialize a raw pointer to it for a safe direct access even when it reside in a STA apartment. This situation is so common that COM provides the custom marshaller that does it. It is the famous Free Threaded Marshaller and since COM does not allow inheritance to reuse code, the only way is to aggregate it to your COM object with the function CoCreateFreeThreadedMarshaler().
Aggregating a COM object just mean that when QueryInterface is called for getting an interface that the outer COM object does not support, it will forward it to the IUnknown::QueryInterface of the aggregated object.
I want you to find in this blog informations about C++ programming that I had a hard time to find in the first place on the web.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
<< < | Current | > >> | ||||
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |