| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -97,10 +97,11 @@ struct _ts { | |||
| 97 | 97 | #ifdef Py_BUILD_CORE | |
| 98 | 98 | # define _PyThreadState_WHENCE_NOTSET -1 | |
| 99 | 99 | # define _PyThreadState_WHENCE_UNKNOWN 0 | |
| 100 | - # define _PyThreadState_WHENCE_INTERP 1 | ||
| 101 | - # define _PyThreadState_WHENCE_THREADING 2 | ||
| 102 | - # define _PyThreadState_WHENCE_GILSTATE 3 | ||
| 103 | - # define _PyThreadState_WHENCE_EXEC 4 | ||
| 100 | + # define _PyThreadState_WHENCE_INIT 1 | ||
| 101 | + # define _PyThreadState_WHENCE_FINI 2 | ||
| 102 | + # define _PyThreadState_WHENCE_THREADING 3 | ||
| 103 | + # define _PyThreadState_WHENCE_GILSTATE 4 | ||
| 104 | + # define _PyThreadState_WHENCE_EXEC 5 | ||
| 104 | 105 | #endif | |
| 105 | 106 | int _whence; | |
| 106 | 107 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -217,10 +217,14 @@ static inline PyInterpreterState* _PyInterpreterState_GET(void) { | |||
| 217 | 217 | ||
| 218 | 218 | // PyThreadState functions | |
| 219 | 219 | ||
| 220 | - extern PyThreadState * _PyThreadState_New( | ||
| 220 | + // Export for _testinternalcapi | ||
| 221 | + PyAPI_FUNC(PyThreadState *) _PyThreadState_New( | ||
| 221 | 222 | PyInterpreterState *interp, | |
| 222 | 223 | int whence); | |
| 223 | 224 | extern void _PyThreadState_Bind(PyThreadState *tstate); | |
| 225 | + PyAPI_FUNC(PyThreadState *) _PyThreadState_NewBound( | ||
| 226 | + PyInterpreterState *interp, | ||
| 227 | + int whence); | ||
| 224 | 228 | extern PyThreadState * _PyThreadState_RemoveExcept(PyThreadState *tstate); | |
| 225 | 229 | extern void _PyThreadState_DeleteList(PyThreadState *list); | |
| 226 | 230 | extern void _PyThreadState_ClearMimallocHeaps(PyThreadState *tstate); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,13 +14,6 @@ extern "C" { | |||
| 14 | 14 | #include "pycore_qsbr.h" // struct qsbr | |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | - static inline void | ||
| 18 | - _PyThreadState_SetWhence(PyThreadState *tstate, int whence) | ||
| 19 | - { | ||
| 20 | - tstate->_whence = whence; | ||
| 21 | - } | ||
| 22 | - | ||
| 23 | - | ||
| 24 | 17 | // Every PyThreadState is actually allocated as a _PyThreadStateImpl. The | |
| 25 | 18 | // PyThreadState fields are exposed as part of the C API, although most fields | |
| 26 | 19 | // are intended to be private. The _PyThreadStateImpl fields not exposed. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1586,8 +1586,8 @@ exec_interpreter(PyObject *self, PyObject *args, PyObject *kwargs) | |||
| 1586 | 1586 | } | |
| 1587 | 1587 | ||
| 1588 | 1588 | PyObject *res = NULL; | |
| 1589 | - PyThreadState *tstate = PyThreadState_New(interp); | ||
| 1590 | - _PyThreadState_SetWhence(tstate, _PyThreadState_WHENCE_EXEC); | ||
| 1589 | + PyThreadState *tstate = | ||
| 1590 | + _PyThreadState_NewBound(interp, _PyThreadState_WHENCE_EXEC); | ||
| 1591 | 1591 | ||
| 1592 | 1592 | PyThreadState *save_tstate = PyThreadState_Swap(tstate); | |
| 1593 | 1593 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1544,8 +1544,7 @@ _enter_session(_PyXI_session *session, PyInterpreterState *interp) | |||
| 1544 | 1544 | PyThreadState *tstate = PyThreadState_Get(); | |
| 1545 | 1545 | PyThreadState *prev = tstate; | |
| 1546 | 1546 | if (interp != tstate->interp) { | |
| 1547 | - tstate = PyThreadState_New(interp); | ||
| 1548 | - _PyThreadState_SetWhence(tstate, _PyThreadState_WHENCE_EXEC); | ||
| 1547 | + tstate = _PyThreadState_NewBound(interp, _PyThreadState_WHENCE_EXEC); | ||
| 1549 | 1548 | // XXX Possible GILState issues? | |
| 1550 | 1549 | session->prev_tstate = PyThreadState_Swap(tstate); | |
| 1551 | 1550 | assert(session->prev_tstate == prev); | |
@@ -1895,8 +1894,7 @@ _PyXI_EndInterpreter(PyInterpreterState *interp, | |||
| 1895 | 1894 | tstate = cur_tstate; | |
| 1896 | 1895 | } | |
| 1897 | 1896 | else { | |
| 1898 | - tstate = PyThreadState_New(interp); | ||
| 1899 | - _PyThreadState_SetWhence(tstate, _PyThreadState_WHENCE_INTERP); | ||
| 1897 | + tstate = _PyThreadState_NewBound(interp, _PyThreadState_WHENCE_FINI); | ||
| 1900 | 1898 | assert(tstate != NULL); | |
| 1901 | 1899 | save_tstate = PyThreadState_Swap(tstate); | |
| 1902 | 1900 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1518,11 +1518,11 @@ switch_to_main_interpreter(PyThreadState *tstate) | |||
| 1518 | 1518 | if (_Py_IsMainInterpreter(tstate->interp)) { | |
| 1519 | 1519 | return tstate; | |
| 1520 | 1520 | } | |
| 1521 | - PyThreadState *main_tstate = PyThreadState_New(_PyInterpreterState_Main()); | ||
| 1521 | + PyThreadState *main_tstate = _PyThreadState_NewBound( | ||
| 1522 | + _PyInterpreterState_Main(), _PyThreadState_WHENCE_EXEC); | ||
| 1522 | 1523 | if (main_tstate == NULL) { | |
| 1523 | 1524 | return NULL; | |
| 1524 | 1525 | } | |
| 1525 | - main_tstate->_whence = _PyThreadState_WHENCE_EXEC; | ||
| 1526 | 1526 | #ifndef NDEBUG | |
| 1527 | 1527 | PyThreadState *old_tstate = PyThreadState_Swap(main_tstate); | |
| 1528 | 1528 | assert(old_tstate == tstate); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -677,7 +677,7 @@ pycore_create_interpreter(_PyRuntimeState *runtime, | |||
| 677 | 677 | } | |
| 678 | 678 | ||
| 679 | 679 | PyThreadState *tstate = _PyThreadState_New(interp, | |
| 680 | - _PyThreadState_WHENCE_INTERP); | ||
| 680 | + _PyThreadState_WHENCE_INIT); | ||
| 681 | 681 | if (tstate == NULL) { | |
| 682 | 682 | return _PyStatus_ERR("can't make first thread"); | |
| 683 | 683 | } | |
@@ -2233,7 +2233,7 @@ new_interpreter(PyThreadState **tstate_p, | |||
| 2233 | 2233 | goto error; | |
| 2234 | 2234 | } | |
| 2235 | 2235 | ||
| 2236 | - tstate = _PyThreadState_New(interp, _PyThreadState_WHENCE_INTERP); | ||
| 2236 | + tstate = _PyThreadState_New(interp, _PyThreadState_WHENCE_INIT); | ||
| 2237 | 2237 | if (tstate == NULL) { | |
| 2238 | 2238 | status = _PyStatus_NO_MEMORY(); | |
| 2239 | 2239 | goto error; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1293,9 +1293,8 @@ _PyInterpreterState_IDDecref(PyInterpreterState *interp) | |||
| 1293 | 1293 | PyThread_release_lock(interp->id_mutex); | |
| 1294 | 1294 | ||
| 1295 | 1295 | if (refcount == 0 && interp->requires_idref) { | |
| 1296 | - PyThreadState *tstate = _PyThreadState_New(interp, | ||
| 1297 | - _PyThreadState_WHENCE_INTERP); | ||
| 1298 | - _PyThreadState_Bind(tstate); | ||
| 1296 | + PyThreadState *tstate = | ||
| 1297 | + _PyThreadState_NewBound(interp, _PyThreadState_WHENCE_FINI); | ||
| 1299 | 1298 | ||
| 1300 | 1299 | // XXX Possible GILState issues? | |
| 1301 | 1300 | PyThreadState *save_tstate = _PyThreadState_Swap(runtime, tstate); | |
@@ -1603,8 +1602,13 @@ new_threadstate(PyInterpreterState *interp, int whence) | |||
| 1603 | 1602 | PyThreadState * | |
| 1604 | 1603 | PyThreadState_New(PyInterpreterState *interp) | |
| 1605 | 1604 | { | |
| 1606 | - PyThreadState *tstate = new_threadstate(interp, | ||
| 1607 | - _PyThreadState_WHENCE_UNKNOWN); | ||
| 1605 | + return _PyThreadState_NewBound(interp, _PyThreadState_WHENCE_UNKNOWN); | ||
| 1606 | + } | ||
| 1607 | + | ||
| 1608 | + PyThreadState * | ||
| 1609 | + _PyThreadState_NewBound(PyInterpreterState *interp, int whence) | ||
| 1610 | + { | ||
| 1611 | + PyThreadState *tstate = new_threadstate(interp, whence); | ||
| 1608 | 1612 | if (tstate) { | |
| 1609 | 1613 | bind_tstate(tstate); | |
| 1610 | 1614 | // This makes sure there's a gilstate tstate bound | |
| Back | FazBrowse Home | New Git URL |
0 commit comments