CComSingleThreadModel

class CComSingleThreadModel

CComSingleThreadModel provides methods for incrementing and decrementing the value of a variable. Unlike CComMultiThreadModel and CComMultiThreadModelNoCS, these methods are not thread-safe.

Typically, you use CComSingleThreadModel through one of two typedef names, either CComObjectThreadModel or CComGlobalsThreadModel. The class referenced by each typedef depends on the threading model used, as shown in the following table:

Threading Model
typedefSingleApartmentFree
CComObjectThreadModelSSM
CComGlobalsThreadModelSMM

S=CComSingleThreadModel; M=CComMultiThreadModel

CComSingleThreadModel itself defines three typedef names. ThreadModelNoCS references CComSingleThreadModel. AutoCriticalSection and CriticalSection reference class CComFakeCriticalSection, which provides empty methods associated with obtaining and releasing ownership of a critical section.

#include <atlbase.h>


CComSingleThreadModel Class Members

Methods
DecrementDecrements the value of the specified variable. This implementation is not thread-safe.
IncrementIncrements the value of the specified variable. This implementation is not thread-safe.
Typedefs
AutoCriticalSectionReferences class CComFakeCriticalSection.
CriticalSectionReferences class CComFakeCriticalSection.
ThreadModelNoCSReferences class CComSingleThreadModel.

CComSingleThreadModel Overview


Methods


CComSingleThreadModel::Decrement

static ULONG Decrement( LPLONG p );

Return Value

The result of the decrement.

Parameters

p [in] Pointer to the variable to be decremented.

Remarks

This static method decrements the value of the variable pointed to by p.

CComSingleThreadModel Overview | Class Members

See Also CComSingleThreadModel::Increment


CComSingleThreadModel::Increment

static ULONG Increment( LPLONG p );

Return Value

The result of the increment.

Parameters

p [in] Pointer to the variable to be incremented.

Remarks

This static method decrements the value of the variable pointed to by p.

CComSingleThreadModel Overview | Class Members

See Also CComSingleThreadModel::Decrement


Typedefs


CComSingleThreadModel::AutoCriticalSection

typedef CComFakeCriticalSection AutoCriticalSection;

Remarks

When using CComSingleThreadModel, the typedef name AutoCriticalSection references class CComFakeCriticalSection. Because CComFakeCriticalSection does not provide a critical section, its methods do nothing.

CComMultiThreadModel and CComMultiThreadModelNoCS also contain definitions for AutoCriticalSection. The following table shows the relationship between the threading model class and the class referenced by AutoCriticalSection:

Class defined inClass referenced
CComSingleThreadModelCComFakeCriticalSection
CComMultiThreadModelCComAutoCriticalSection
CComMultiThreadModelNoCSCComFakeCriticalSection

In addition to AutoCriticalSection, you can use the typedef name CriticalSection. You should not specify AutoCriticalSection in global objects or static class members if you want to eliminate the CRT startup code.

Example

See CComMultiThreadModel::AutoCriticalSection.

CComSingleThreadModel Overview | Class Members

See Also CComObjectThreadModel, CComGlobalsThreadModel, CComSingleThreadModel::ThreadModelNoCS


CComSingleThreadModel::CriticalSection

typedef CComFakeCriticalSection CriticalSection;

Remarks

When using CComSingleThreadModel, the typedef name CriticalSection references class CComFakeCriticalSection. Because CComFakeCriticalSection does not provide a critical section, its methods do nothing.

CComMultiThreadModel and CComMultiThreadModelNoCS also contain definitions for CriticalSection. The following table shows the relationship between the threading model class and the class referenced by CriticalSection:

Class defined inClass referenced
CComSingleThreadModelCComFakeCriticalSection
CComMultiThreadModelCComCriticalSection
CComMultiThreadModelNoCSCComFakeCriticalSection

In addition to CriticalSection, you can use the typedef name AutoCriticalSection. You should not specify AutoCriticalSection in global objects or static class members if you want to eliminate the CRT startup code.

Example

See CComMultiThreadModel::AutoCriticalSection.

CComSingleThreadModel Overview | Class Members

See Also CComObjectThreadModel, CComGlobalsThreadModel, CComSingleThreadModel::ThreadModelNoCS


CComSingleThreadModel::ThreadModelNoCS

typedef CComSingleThreadModel ThreadModelNoCS;

Remarks

When using CComSingleThreadModel, the typedef name ThreadModelNoCS simply references CComSingleThreadModel.

CComMultiThreadModel and CComMultiThreadModelNoCS also contain definitions for ThreadModelNoCS. The following table shows the relationship between the threading model class and the class referenced by ThreadModelNoCS:

Class defined inClass referenced
CComSingleThreadModelCComSingleThreadModel
CComMultiThreadModelCComMultiThreadModelNoCS
CComMultiThreadModelNoCSCComMultiThreadModelNoCS

Example

See CComMultiThreadModel::AutoCriticalSection.

CComSingleThreadModel Overview | Class Members

See Also CComObjectThreadModel, CComGlobalsThreadModel