COM activation models
From: Headache (rquirk_at_tandbergtv.com)
Date: 12/20/04
- Next message: ATS: "Re: HOWTO create new multi-threading ATL/COM object."
- Previous message: smalolepszy: "CAtlREMatchContext and special characters"
- Next in thread: Igor Tandetnik: "Re: COM activation models"
- Reply: Igor Tandetnik: "Re: COM activation models"
- Messages sorted by: [ date ] [ thread ]
Date: 20 Dec 2004 01:36:53 -0800
I have a freee threaded out-of-process (.exe) server which exposes one
COM object that is CComMultiThread model. When a client accesses the
server's COM object using CoCreateInstance I see no evidence of the
server's main thread running. I've read 'Essential COM' by Don Box and
the section 'Activation and the SCM' says the following:
When calling CoRegisterClassObject, the COM library holds a reference
to the class object provided as the second parameter and associates
the class object with its CLSID in an internally maintained table.
Depending on the activation flags used in the call, the COM library
may also notify the local SCM that the CALLER'S PROCESS IS NOW THE
SERVER PROCESS FOR THE DESIGNATED CLASS.
I'm guessing this is why I don't see the server's main thread
ATLTRACE?
Apparently at odds with this statement (IMHO) is a satement later
which says:
Server processes can register class objects for more than one class.
If the class objects are registered to run in the MTA of the process,
this means that incoming activation requests may be serviced as soon
as the first call to CoRegisterClassObject completes. In any MTA-based
servers this can cause problems .. so REG_CLS_SUSPENDED was introduced
with a call to CoResumeClassObjects.
Now, the server code has the following ON THE PRIMARY THREAD
#if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED);
_ASSERTE(SUCCEEDED(hRes));
hRes = CoResumeClassObjects();
ATLTRACE("Main thread CoResumeClassObjects");
#else
Would I expect to have to see this code execute (ie. the main thread)
for each activation request or is it only necessary to do it once
using /regserver for the SCM?
The whole reason for this is I need to create a particular
multi-threaded COM singleton on the main thread. To do this I have
overriden CComClassFactorySingleton (created
CComClassFactorySingletonOnMainThread) and have used
DECLARE_COM_CLASSFACTORY_EX. Running the server standalone the class
factory's overridden CreateInstance is entered. However, running it
from a CoCreateInstance in a client does not even seem to get the
server's main thread up and running let alone enter my ClassFactory's
CoCreateInstance!
For reason's best kept secret I can't use CComSingleThreadedModel for
the singleton.
Questions are:
Can I cause the server's main thread to run by effectively changing
the activation flags used in CoRegisterClassObject or ...
Is there any way I can force COM MTA object activation onto the main
thread given the observation that the server's main thread does not
appear to run?
Hope that's clear!
TIA
- Next message: ATS: "Re: HOWTO create new multi-threading ATL/COM object."
- Previous message: smalolepszy: "CAtlREMatchContext and special characters"
- Next in thread: Igor Tandetnik: "Re: COM activation models"
- Reply: Igor Tandetnik: "Re: COM activation models"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|