mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +00:00
gh-104530: Enable native Win32 condition variables by default (GH-104531)
This commit is contained in:
parent
d29f57f603
commit
b3f0b698da
6 changed files with 41 additions and 35 deletions
|
@ -260,13 +260,13 @@ PyMUTEX_UNLOCK(PyMUTEX_T *cs)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Py_LOCAL_INLINE(int)
|
||||
PyCOND_INIT(PyCOND_T *cv)
|
||||
{
|
||||
InitializeConditionVariable(cv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py_LOCAL_INLINE(int)
|
||||
PyCOND_FINI(PyCOND_T *cv)
|
||||
{
|
||||
|
@ -279,27 +279,32 @@ PyCOND_WAIT(PyCOND_T *cv, PyMUTEX_T *cs)
|
|||
return SleepConditionVariableSRW(cv, cs, INFINITE, 0) ? 0 : -1;
|
||||
}
|
||||
|
||||
/* This implementation makes no distinction about timeouts. Signal
|
||||
* 2 to indicate that we don't know.
|
||||
*/
|
||||
/* return 0 for success, 1 on timeout, -1 on error */
|
||||
Py_LOCAL_INLINE(int)
|
||||
PyCOND_TIMEDWAIT(PyCOND_T *cv, PyMUTEX_T *cs, long long us)
|
||||
{
|
||||
return SleepConditionVariableSRW(cv, cs, (DWORD)(us/1000), 0) ? 2 : -1;
|
||||
BOOL success = SleepConditionVariableSRW(cv, cs, (DWORD)(us/1000), 0);
|
||||
if (!success) {
|
||||
if (GetLastError() == ERROR_TIMEOUT) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py_LOCAL_INLINE(int)
|
||||
PyCOND_SIGNAL(PyCOND_T *cv)
|
||||
{
|
||||
WakeConditionVariable(cv);
|
||||
return 0;
|
||||
WakeConditionVariable(cv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py_LOCAL_INLINE(int)
|
||||
PyCOND_BROADCAST(PyCOND_T *cv)
|
||||
{
|
||||
WakeAllConditionVariable(cv);
|
||||
return 0;
|
||||
WakeAllConditionVariable(cv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue