mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). (gh-12360)
This is effectively an un-revert of #11617 and #12024 (reverted in #12159). Portions of those were merged in other PRs (with lower risk) and this represents the remainder. Note that I found 3 different bugs in the original PRs and have fixed them here.
This commit is contained in:
parent
44235041f3
commit
f13c5c8b94
11 changed files with 151 additions and 108 deletions
|
@ -176,7 +176,7 @@ static void drop_gil(PyThreadState *tstate)
|
|||
&_PyRuntime.ceval.gil.last_holder)
|
||||
) == tstate)
|
||||
{
|
||||
RESET_GIL_DROP_REQUEST();
|
||||
RESET_GIL_DROP_REQUEST(tstate->interp);
|
||||
/* NOTE: if COND_WAIT does not atomically start waiting when
|
||||
releasing the mutex, another thread can run through, take
|
||||
the GIL and drop it again, and reset the condition
|
||||
|
@ -213,7 +213,7 @@ static void take_gil(PyThreadState *tstate)
|
|||
if (timed_out &&
|
||||
_Py_atomic_load_relaxed(&_PyRuntime.ceval.gil.locked) &&
|
||||
_PyRuntime.ceval.gil.switch_number == saved_switchnum) {
|
||||
SET_GIL_DROP_REQUEST();
|
||||
SET_GIL_DROP_REQUEST(tstate->interp);
|
||||
}
|
||||
}
|
||||
_ready:
|
||||
|
@ -239,10 +239,10 @@ _ready:
|
|||
MUTEX_UNLOCK(_PyRuntime.ceval.gil.switch_mutex);
|
||||
#endif
|
||||
if (_Py_atomic_load_relaxed(&_PyRuntime.ceval.gil_drop_request)) {
|
||||
RESET_GIL_DROP_REQUEST();
|
||||
RESET_GIL_DROP_REQUEST(tstate->interp);
|
||||
}
|
||||
if (tstate->async_exc != NULL) {
|
||||
_PyEval_SignalAsyncExc();
|
||||
_PyEval_SignalAsyncExc(tstate->interp);
|
||||
}
|
||||
|
||||
MUTEX_UNLOCK(_PyRuntime.ceval.gil.mutex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue