summaryrefslogtreecommitdiffstats
path: root/Python/ceval_gil.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-05-05 14:14:31 (GMT)
committerGitHub <noreply@github.com>2020-05-05 14:14:31 (GMT)
commit0b1e3307e24b0af45787ab6456535b8346e0239a (patch)
treea1dc53188efc9af1478f3c9fe707bbaac02f1224 /Python/ceval_gil.h
parent4e01946cafca0cf49f796c3118e0d65237bcad69 (diff)
downloadcpython-0b1e3307e24b0af45787ab6456535b8346e0239a.zip
cpython-0b1e3307e24b0af45787ab6456535b8346e0239a.tar.gz
cpython-0b1e3307e24b0af45787ab6456535b8346e0239a.tar.bz2
bpo-40513: Per-interpreter gil_drop_request (GH-19927)
Move gil_drop_request member from _PyRuntimeState.ceval to PyInterpreterState.ceval.
Diffstat (limited to 'Python/ceval_gil.h')
-rw-r--r--Python/ceval_gil.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/Python/ceval_gil.h b/Python/ceval_gil.h
index a025a9f..db47077 100644
--- a/Python/ceval_gil.h
+++ b/Python/ceval_gil.h
@@ -141,7 +141,8 @@ static void recreate_gil(struct _gil_runtime_state *gil)
}
static void
-drop_gil(struct _ceval_runtime_state *ceval, PyThreadState *tstate)
+drop_gil(struct _ceval_runtime_state *ceval, struct _ceval_state *ceval2,
+ PyThreadState *tstate)
{
struct _gil_runtime_state *gil = &ceval->gil;
if (!_Py_atomic_load_relaxed(&gil->locked)) {
@@ -163,7 +164,7 @@ drop_gil(struct _ceval_runtime_state *ceval, PyThreadState *tstate)
MUTEX_UNLOCK(gil->mutex);
#ifdef FORCE_SWITCHING
- if (_Py_atomic_load_relaxed(&ceval->gil_drop_request) && tstate != NULL) {
+ if (_Py_atomic_load_relaxed(&ceval2->gil_drop_request) && tstate != NULL) {
MUTEX_LOCK(gil->switch_mutex);
/* Not switched yet => wait */
if (((PyThreadState*)_Py_atomic_load_relaxed(&gil->last_holder)) == tstate)
@@ -226,6 +227,7 @@ take_gil(PyThreadState *tstate)
assert(is_tstate_valid(tstate));
PyInterpreterState *interp = tstate->interp;
struct _ceval_runtime_state *ceval = &interp->runtime->ceval;
+ struct _ceval_state *ceval2 = &interp->ceval;
struct _gil_runtime_state *gil = &ceval->gil;
/* Check that _PyEval_InitThreads() was called to create the lock */
@@ -289,12 +291,12 @@ _ready:
in take_gil() while the main thread called
wait_for_thread_shutdown() from Py_Finalize(). */
MUTEX_UNLOCK(gil->mutex);
- drop_gil(ceval, tstate);
+ drop_gil(ceval, ceval2, tstate);
PyThread_exit_thread();
}
assert(is_tstate_valid(tstate));
- if (_Py_atomic_load_relaxed(&ceval->gil_drop_request)) {
+ if (_Py_atomic_load_relaxed(&ceval2->gil_drop_request)) {
RESET_GIL_DROP_REQUEST(interp);
}
else {
@@ -303,8 +305,7 @@ _ready:
handle signals.
Note: RESET_GIL_DROP_REQUEST() calls COMPUTE_EVAL_BREAKER(). */
- struct _ceval_state *ceval2 = &interp->ceval;
- COMPUTE_EVAL_BREAKER(interp, ceval, ceval2);
+ COMPUTE_EVAL_BREAKER(interp, ceval2);
}
/* Don't access tstate if the thread must exit */