CComObjectThreadModel
Calls the appropriate thread model methods, regardless of the threading model being used.
#if defined( _ATL_SINGLE_THREADED )
typedef CComSingleThreadModel CComObjectThreadModel;
#elif defined( _ATL_APARTMENT_THREADED )
typedef CComSingleThreadModel CComObjectThreadModel;
#elif defined( _ATL_FREE_THREADED )
typedef CComMultiThreadModel CComObjectThreadModel;
#else
#pragma message ("No global threading model defined")
#endif
Remarks
Depending on the threading model used by your application, the typedef name CComObjectThreadModel references either CComSingleThreadModel or CComMultiThreadModel. These classes provide additional typedef names to reference a critical section class.
Nota
CComObjectThreadModel does not reference class CComMultiThreadModelNoCS.
Using CComObjectThreadModel frees you from specifying a particular threading model class. Regardless of the threading model being used, the appropriate methods will be called.
In addition to CComObjectThreadModel, ATL provides the typedef name CComGlobalsThreadModel. The class referenced by each typedef depends on the threading model used, as shown in the following table:
typedef |
Single threading |
Apartment threading |
Free threading |
---|---|---|---|
CComObjectThreadModel |
S |
S |
M |
CComGlobalsThreadModel |
S |
M |
M |
S=CComSingleThreadModel; M=CComMultiThreadModel
Use CComObjectThreadModel within a single object class. Use CComGlobalsThreadModel in an object that is either globally available to your program, or when you want to protect module resources across multiple threads.
Requirements
Header: atlbase.h