diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-06-03 16:14:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-03 16:14:24 (GMT) |
commit | e225bebc1409bcf68db74a35ed3c31222883bf8f (patch) | |
tree | 42153d2d48a3f1c784812b4fb54ed3557be713d0 /Python/ceval_gil.h | |
parent | 49a7e347976c9b39149ac7505b11ad6e9e2bdeec (diff) | |
download | cpython-e225bebc1409bcf68db74a35ed3c31222883bf8f.zip cpython-e225bebc1409bcf68db74a35ed3c31222883bf8f.tar.gz cpython-e225bebc1409bcf68db74a35ed3c31222883bf8f.tar.bz2 |
Revert "bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). (gh-13714)" (GH-13780)
This reverts commit 6a150bcaeb190d1731b38ab9c7a5d1a352847ddc.
Diffstat (limited to 'Python/ceval_gil.h')
-rw-r--r-- | Python/ceval_gil.h | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/Python/ceval_gil.h b/Python/ceval_gil.h index b44d0ab..34d48c9 100644 --- a/Python/ceval_gil.h +++ b/Python/ceval_gil.h @@ -141,11 +141,9 @@ static void recreate_gil(struct _gil_runtime_state *gil) } static void -drop_gil(struct _ceval_runtime_state *ceval_r, - struct _ceval_interpreter_state *ceval_i, - PyThreadState *tstate) +drop_gil(struct _ceval_runtime_state *ceval, PyThreadState *tstate) { - struct _gil_runtime_state *gil = &ceval_r->gil; + struct _gil_runtime_state *gil = &ceval->gil; if (!_Py_atomic_load_relaxed(&gil->locked)) { Py_FatalError("drop_gil: GIL is not locked"); } @@ -165,12 +163,12 @@ drop_gil(struct _ceval_runtime_state *ceval_r, MUTEX_UNLOCK(gil->mutex); #ifdef FORCE_SWITCHING - if (_Py_atomic_load_relaxed(&ceval_r->gil_drop_request) && tstate != NULL) { + if (_Py_atomic_load_relaxed(&ceval->gil_drop_request) && tstate != NULL) { MUTEX_LOCK(gil->switch_mutex); /* Not switched yet => wait */ if (((PyThreadState*)_Py_atomic_load_relaxed(&gil->last_holder)) == tstate) { - RESET_GIL_DROP_REQUEST(ceval_r, ceval_i); + RESET_GIL_DROP_REQUEST(ceval); /* 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 @@ -183,19 +181,13 @@ drop_gil(struct _ceval_runtime_state *ceval_r, } static void -take_gil(struct _ceval_runtime_state *ceval_r, - PyThreadState *tstate) +take_gil(struct _ceval_runtime_state *ceval, PyThreadState *tstate) { if (tstate == NULL) { Py_FatalError("take_gil: NULL tstate"); } - PyInterpreterState *interp = tstate->interp; - if (interp == NULL) { - Py_FatalError("take_gil: NULL interp"); - } - struct _ceval_interpreter_state *ceval_i = &interp->ceval; - struct _gil_runtime_state *gil = &ceval_r->gil; + struct _gil_runtime_state *gil = &ceval->gil; int err = errno; MUTEX_LOCK(gil->mutex); @@ -218,7 +210,7 @@ take_gil(struct _ceval_runtime_state *ceval_r, _Py_atomic_load_relaxed(&gil->locked) && gil->switch_number == saved_switchnum) { - SET_GIL_DROP_REQUEST(ceval_r); + SET_GIL_DROP_REQUEST(ceval); } } _ready: @@ -240,11 +232,11 @@ _ready: COND_SIGNAL(gil->switch_cond); MUTEX_UNLOCK(gil->switch_mutex); #endif - if (_Py_atomic_load_relaxed(&ceval_r->gil_drop_request)) { - RESET_GIL_DROP_REQUEST(ceval_r, ceval_i); + if (_Py_atomic_load_relaxed(&ceval->gil_drop_request)) { + RESET_GIL_DROP_REQUEST(ceval); } if (tstate->async_exc != NULL) { - _PyEval_SignalAsyncExc(ceval_r, ceval_i); + _PyEval_SignalAsyncExc(ceval); } MUTEX_UNLOCK(gil->mutex); |