SleepConditionVariableSRW function
Applies to: desktop apps | Metro style apps
Sleeps on the specified condition variable and releases the specified lock as an atomic operation.
Syntax
BOOL WINAPI SleepConditionVariableSRW( __inout PCONDITION_VARIABLE ConditionVariable, __inout PSRWLOCK SRWLock, __in DWORD dwMilliseconds, __in ULONG Flags );
Parameters
- ConditionVariable [in, out]
-
A pointer to the condition variable. This variable must be initialized using the InitializeConditionVariable function.
- SRWLock [in, out]
-
A pointer to the lock. This lock must be held in the manner specified by the Flags parameter.
- dwMilliseconds [in]
-
The time-out interval, in milliseconds. The function returns if the interval elapses. If dwMilliseconds is zero, the function tests the states of the specified objects and returns immediately. If dwMilliseconds is INFINITE, the function's time-out interval never elapses.
- Flags [in]
-
If this parameter is CONDITION_VARIABLE_LOCKMODE_SHARED, the SRW lock is in shared mode. Otherwise, the lock is in exclusive mode.
Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
If the lock is unlocked when this function is called, the function behavior is undefined.
The thread can be woken using the WakeConditionVariable or WakeAllConditionVariable function.
Condition variables are subject to spurious wakeups (those not associated with an explicit wake) and stolen wakeups (another thread manages to run before the woken thread). Therefore, you should recheck a predicate (typically in a while loop) after a sleep operation returns.
Requirements
|
Minimum supported client | Windows Vista |
|---|---|
|
Minimum supported server | Windows Server 2008 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 3/7/2012