mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
bpo-36084: Add native thread ID (TID) to threading.Thread (GH-13463)
Add native thread ID (TID) to threading.Thread objects (supported platforms: Windows, FreeBSD, Linux, macOS).
This commit is contained in:
parent
b3be407288
commit
b121f63155
9 changed files with 154 additions and 0 deletions
|
|
@ -143,6 +143,10 @@ LeaveNonRecursiveMutex(PNRMUTEX mutex)
|
|||
|
||||
unsigned long PyThread_get_thread_ident(void);
|
||||
|
||||
#ifdef PY_HAVE_THREAD_NATIVE_ID
|
||||
unsigned long PyThread_get_thread_native_id(void);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initialization of the C package, should not be needed.
|
||||
*/
|
||||
|
|
@ -227,6 +231,25 @@ PyThread_get_thread_ident(void)
|
|||
return GetCurrentThreadId();
|
||||
}
|
||||
|
||||
#ifdef PY_HAVE_THREAD_NATIVE_ID
|
||||
/*
|
||||
* Return the native Thread ID (TID) of the calling thread.
|
||||
* The native ID of a thread is valid and guaranteed to be unique system-wide
|
||||
* from the time the thread is created until the thread has been terminated.
|
||||
*/
|
||||
unsigned long
|
||||
PyThread_get_thread_native_id(void)
|
||||
{
|
||||
if (!initialized) {
|
||||
PyThread_init_thread();
|
||||
}
|
||||
|
||||
DWORD native_id;
|
||||
native_id = GetCurrentThreadId();
|
||||
return (unsigned long) native_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
void _Py_NO_RETURN
|
||||
PyThread_exit_thread(void)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue