#if defined( _ATL_SINGLE_THREADED )
typedef CComSingleThreadModel CComGlobalsThreadModel;
#elif defined( _ATL_APARTMENT_THREADED )
typedef CComMultiThreadModel CComGlobalsThreadModel;
#else
typedef CComMultiThreadModel CComGlobalsThreadModel;
#endif
Depending on the threading model used by your application, the typedef name CComGlobalsThreadModel references either CComSingleThreadModel or CComMultiThreadModel. These classes provide additional typedef names to reference a critical section class.
Note CComGlobalsThreadModel does not reference class CComMultiThreadModelNoCS.
Using CComGlobalsThreadModel 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 CComGlobalsThreadModel, ATL provides the typedef name CComObjectThreadModel. The class referenced by each typedef depends on the threading model used, as shown in the following table:
Threading Model | |||
typedef | Single | Apartment | Free |
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 globally available to your program, or when you wish to protect module resources across multiple threads.
#include <atlbase.h>
See Also CComObjectRootEx