CComMultiThreadModelNoCS

class CComMultiThreadModelNoCS

CComMultiThreadModelNoCS is similar to CComMultiThreadModel in that it provides thread-safe methods for incrementing and decrementing a variable. However, when you reference a critical section class through CComMultiThreadModelNoCS, methods such as Lock and Unlock will do nothing.

Typically, you use CComMultiThreadModelNoCS through the ThreadModelNoCS typedef name. This typedef is defined in CComMultiThreadModelNoCS, CComMultiThreadModel, and CComSingleThreadModel.

Note The global typedef names CComObjectThreadModel and CComGlobalsThreadModel do not reference CComMultiThreadModelNoCS.

In addition to ThreadModelNoCS, CComMultiThreadModelNoCS defines AutoCriticalSection and CriticalSection. These latter two typedef names reference CComFakeCriticalSection, which provides empty methods associated with obtaining and releasing a critical section.

#include <atlbase.h>

Class Members


CComMultiThreadModelNoCS Class Members

Methods
DecrementDecrements the value of the specified variable in a thread-safe manner.
IncrementIncrements the value of the specified variable in a thread-safe manner.
Typedefs
AutoCriticalSectionReferences class CComFakeCriticalSection.
CriticalSectionReferences class CComFakeCriticalSection.
ThreadModelNoCSReferences class CComMultiThreadModelNoCS.

CComMultiThreadModelNoCS Overview


Methods


CComMultiThreadModelNoCS::Decrement

static ULONG Decrement( LPLONG p );

Return Value

If the result of the decrement is 0, then Decrement returns 0. If the result of the decrement is nonzero, the return value is also nonzero but may not equal the result of the decrement.

Parameters

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

Remarks

This static method calls the Win32 function InterlockedDecrement, which decrements the value of the variable pointed to by p. InterlockedDecrement prevents more than one thread from simultaneously using this variable.

CComMultiThreadModelNoCS Overview | Class Members

See Also CComMultiThreadModelNoCS::Increment, InterlockedDecrement in the Win32 SDK


CComMultiThreadModelNoCS::Increment

static ULONG Increment( LPLONG p );

Return Value

If the result of the increment is 0, then Increment returns 0. If the result of the increment is nonzero, the return value is also nonzero but may not equal the result of the increment.

Parameters

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

Remarks

This static method calls the Win32 function InterlockedIncrement, which increments the value of the variable pointed to by p. InterlockedIncrement prevents more than one thread from simultaneously using this variable.

CComMultiThreadModelNoCS Overview | Class Members

See Also CComMultiThreadModelNoCS::Decrement, InterlockedIncrement in the Win32 SDK


Typedefs


CComMultiThreadModelNoCS::AutoCriticalSection

typedef CComFakeCriticalSection AutoCriticalSection;

Remarks

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

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

Class defined inClass referenced
CComMultiThreadModelNoCSCComFakeCriticalSection
CComMultiThreadModelCComAutoCriticalSection
CComSingleThreadModelCComFakeCriticalSection

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.

CComMultiThreadModelNoCS Overview | Class Members

See Also CComObjectThreadModel, CComGlobalsThreadModel, CComMultiThreadModelNoCS::ThreadModelNoCS


CComMultiThreadModelNoCS::CriticalSection

typedef CComFakeCriticalSection CriticalSection;

Remarks

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

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

Class defined inClass referenced
CComMultiThreadModelNoCSCComFakeCriticalSection
CComMultiThreadModelCComCriticalSection
CComSingleThreadModelCComFakeCriticalSection

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.

CComMultiThreadModelNoCS Overview | Class Members

See Also CComObjectThreadModel, CComGlobalsThreadModel, CComMultiThreadModelNoCS::ThreadModelNoCS


CComMultiThreadModelNoCS::ThreadModelNoCS

typedef CComMultiThreadModelNoCS ThreadModelNoCS;

Remarks

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

CComMultiThreadModel and CComSingleThreadModel 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
CComMultiThreadModelNoCSCComMultiThreadModelNoCS
CComMultiThreadModelCComMultiThreadModelNoCS
CComSingleThreadModelCComSingleThreadModel

Example

See CComMultiThreadModel::AutoCriticalSection.

Note that the definition of ThreadModelNoCS in CComMultiThreadModelNoCS provides symmetry with CComMultiThreadModel and CComSingleThreadModel. For example, suppose the sample code in CComMultiThreadModel::AutoCriticalSection declared the following typedef:

typedef ThreadModel::ThreadModelNoCS _ThreadModel;

Regardless of the class specified for ThreadModel (such as CComMultiThreadModelNoCS), _ThreadModel resolves accordingly.

CComMultiThreadModelNoCS Overview | Class Members

See Also CComObjectThreadModel, CComGlobalsThreadModel