mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
[3.14] gh-135871: Fix needless spinning in _PyMutex_LockTimed
with zero timeout (gh-135872) (gh-135946)
The free threading build could spin unnecessarily on `_Py_yield()` if the initial
compare and swap failed.
(cherry picked from commit cbfaf41caf
)
Co-authored-by: Joseph Tibbertsma <josephtibbertsma@gmail.com>
This commit is contained in:
parent
df1c124240
commit
80fc62f8af
2 changed files with 3 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
Non-blocking mutex lock attempts now return immediately when the lock is busy
|
||||
instead of briefly spinning in the :term:`free threading` build.
|
|
@ -58,7 +58,7 @@ _PyMutex_LockTimed(PyMutex *m, PyTime_t timeout, _PyLockFlags flags)
|
|||
return PY_LOCK_ACQUIRED;
|
||||
}
|
||||
}
|
||||
else if (timeout == 0) {
|
||||
if (timeout == 0) {
|
||||
return PY_LOCK_FAILURE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue