mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
gh-81057: Move More Globals in Core Code to _PyRuntimeState (gh-99516)
https://github.com/python/cpython/issues/81057
This commit is contained in:
parent
5cfb7d19f5
commit
5f55067e23
24 changed files with 241 additions and 130 deletions
|
@ -137,8 +137,8 @@ init_runtime(_PyRuntimeState *runtime,
|
|||
// Set it to the ID of the main thread of the main interpreter.
|
||||
runtime->main_thread = PyThread_get_thread_ident();
|
||||
|
||||
runtime->unicode_ids.next_index = unicode_next_index;
|
||||
runtime->unicode_ids.lock = unicode_ids_mutex;
|
||||
runtime->unicode_state.ids.next_index = unicode_next_index;
|
||||
runtime->unicode_state.ids.lock = unicode_ids_mutex;
|
||||
|
||||
runtime->_initialized = 1;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ _PyRuntimeState_Init(_PyRuntimeState *runtime)
|
|||
_Py_AuditHookEntry *audit_hook_head = runtime->audit_hook_head;
|
||||
// bpo-42882: Preserve next_index value if Py_Initialize()/Py_Finalize()
|
||||
// is called multiple times.
|
||||
Py_ssize_t unicode_next_index = runtime->unicode_ids.next_index;
|
||||
Py_ssize_t unicode_next_index = runtime->unicode_state.ids.next_index;
|
||||
|
||||
PyThread_type_lock lock1, lock2, lock3, lock4;
|
||||
if (alloc_for_runtime(&lock1, &lock2, &lock3, &lock4) != 0) {
|
||||
|
@ -186,7 +186,7 @@ _PyRuntimeState_Fini(_PyRuntimeState *runtime)
|
|||
|
||||
FREE_LOCK(runtime->interpreters.mutex);
|
||||
FREE_LOCK(runtime->xidregistry.mutex);
|
||||
FREE_LOCK(runtime->unicode_ids.lock);
|
||||
FREE_LOCK(runtime->unicode_state.ids.lock);
|
||||
FREE_LOCK(runtime->getargs.mutex);
|
||||
|
||||
#undef FREE_LOCK
|
||||
|
@ -209,7 +209,7 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime)
|
|||
|
||||
int reinit_interp = _PyThread_at_fork_reinit(&runtime->interpreters.mutex);
|
||||
int reinit_xidregistry = _PyThread_at_fork_reinit(&runtime->xidregistry.mutex);
|
||||
int reinit_unicode_ids = _PyThread_at_fork_reinit(&runtime->unicode_ids.lock);
|
||||
int reinit_unicode_ids = _PyThread_at_fork_reinit(&runtime->unicode_state.ids.lock);
|
||||
int reinit_getargs = _PyThread_at_fork_reinit(&runtime->getargs.mutex);
|
||||
|
||||
PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue