mirror of https://github.com/python/cpython
bpo-43879: Add native_thread_id field to PyThreadState (GH-25458)
This commit is contained in:
parent
4f725261c6
commit
90a6c07cb2
|
@ -113,6 +113,12 @@ struct _ts {
|
||||||
PyObject *async_exc; /* Asynchronous exception to raise */
|
PyObject *async_exc; /* Asynchronous exception to raise */
|
||||||
unsigned long thread_id; /* Thread id where this tstate was created */
|
unsigned long thread_id; /* Thread id where this tstate was created */
|
||||||
|
|
||||||
|
/* Native thread id where this tstate was created. This will be 0 except on
|
||||||
|
* those platforms that have the notion of native thread id, for which the
|
||||||
|
* macro PY_HAVE_THREAD_NATIVE_ID is then defined.
|
||||||
|
*/
|
||||||
|
unsigned long native_thread_id;
|
||||||
|
|
||||||
int trash_delete_nesting;
|
int trash_delete_nesting;
|
||||||
PyObject *trash_delete_later;
|
PyObject *trash_delete_later;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Add native_thread_id to PyThreadState. Patch by Gabriele N. Tornetta.
|
|
@ -1071,6 +1071,11 @@ thread_run(void *boot_raw)
|
||||||
|
|
||||||
tstate = boot->tstate;
|
tstate = boot->tstate;
|
||||||
tstate->thread_id = PyThread_get_thread_ident();
|
tstate->thread_id = PyThread_get_thread_ident();
|
||||||
|
#ifdef PY_HAVE_THREAD_NATIVE_ID
|
||||||
|
tstate->native_thread_id = PyThread_get_thread_native_id();
|
||||||
|
#else
|
||||||
|
tstate->native_thread_id = 0;
|
||||||
|
#endif
|
||||||
_PyThreadState_Init(tstate);
|
_PyThreadState_Init(tstate);
|
||||||
PyEval_AcquireThread(tstate);
|
PyEval_AcquireThread(tstate);
|
||||||
tstate->interp->num_threads++;
|
tstate->interp->num_threads++;
|
||||||
|
|
|
@ -645,6 +645,11 @@ new_threadstate(PyInterpreterState *interp, int init)
|
||||||
tstate->gilstate_counter = 0;
|
tstate->gilstate_counter = 0;
|
||||||
tstate->async_exc = NULL;
|
tstate->async_exc = NULL;
|
||||||
tstate->thread_id = PyThread_get_thread_ident();
|
tstate->thread_id = PyThread_get_thread_ident();
|
||||||
|
#ifdef PY_HAVE_THREAD_NATIVE_ID
|
||||||
|
tstate->native_thread_id = PyThread_get_thread_native_id();
|
||||||
|
#else
|
||||||
|
tstate->native_thread_id = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
tstate->dict = NULL;
|
tstate->dict = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue