description | title | ms.date | ms.topic | f1_keywords | helpviewer_keywords | ms.assetid | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: CriticalSection Class |
CriticalSection Class |
09/24/2018 |
reference |
|
|
f2e0a024-71a3-4f6b-99ea-d93a4a608ac4 |
Represents a critical section object.
class CriticalSection;
Name | Description |
---|---|
CriticalSection::CriticalSection | Initializes a synchronization object that is similar to a mutex object, but can be used by only the threads of a single process. |
CriticalSection::~CriticalSection | Deinitializes and destroys the current CriticalSection object. |
Name | Description |
---|---|
CriticalSection::IsValid | Indicates whether the current critical section is valid. |
CriticalSection::Lock | Waits for ownership of the specified critical section object. The function returns when the calling thread is granted ownership. |
CriticalSection::TryLock | Attempts to enter a critical section without blocking. If the call is successful, the calling thread takes ownership of the critical section. |
Name | Description |
---|---|
CriticalSection::cs_ | Declares a critical section data member. |
CriticalSection
Header: corewrappers.h
Namespace: Microsoft::WRL::Wrappers
Deinitializes and destroys the current CriticalSection
object.
WRL_NOTHROW ~CriticalSection();
Initializes a synchronization object that is similar to a mutex object, but can be used by only the threads of a single process.
explicit CriticalSection(
ULONG spincount = 0
);
spincount
The spin count for the critical section object. The default value is 0.
For more information about critical sections and spincounts, see the InitializeCriticalSectionAndSpinCount
function in the Synchronization
section of the Windows API documentation.
Declares a critical section data member.
CRITICAL_SECTION cs_;
This data member is protected.
Indicates whether the current critical section is valid.
bool IsValid() const;
By default, always returns true
.
Waits for ownership of the specified critical section object. The function returns when the calling thread is granted ownership.
SyncLock Lock();
static SyncLock Lock(
_In_ CRITICAL_SECTION* cs
);
cs
A user-specified critical section object.
A lock object that can be used to unlock the current critical section.
The first Lock
function affects the current critical section object. The second Lock
function affects a user-specified critical section.
Attempts to enter a critical section without blocking. If the call is successful, the calling thread takes ownership of the critical section.
SyncLock TryLock();
static SyncLock TryLock(
_In_ CRITICAL_SECTION* cs
);
cs
A user-specified critical section object.
A nonzero value if the critical section is successfully entered or the current thread already owns the critical section. Zero if another thread already owns the critical section.
The first TryLock
function affects the current critical section object. The second TryLock
function affects a user-specified critical section.