diff options
| author | AlexSm <[email protected]> | 2024-02-16 11:51:30 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-02-16 11:51:30 +0100 |
| commit | 506ecaee93b52cc12c2e2f97c3d42e3ca2a7f59e (patch) | |
| tree | d096fb9eb988fbb0ca1ba970041773207ce3aa70 /contrib/tools/python3/src/Python/thread_nt.h | |
| parent | 4749b9e5d260714490997e6f5ee1ee8c1c8fc46c (diff) | |
| parent | f200f72c9d7a89c1018e3dc6b46c49fe2ecf84fb (diff) | |
Merge pull request #1940 from dcherednik/importlib
Library import 14
Diffstat (limited to 'contrib/tools/python3/src/Python/thread_nt.h')
| -rw-r--r-- | contrib/tools/python3/src/Python/thread_nt.h | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/contrib/tools/python3/src/Python/thread_nt.h b/contrib/tools/python3/src/Python/thread_nt.h index 084bd587314..26f441bd6d3 100644 --- a/contrib/tools/python3/src/Python/thread_nt.h +++ b/contrib/tools/python3/src/Python/thread_nt.h @@ -152,11 +152,12 @@ unsigned long PyThread_get_thread_native_id(void); #endif /* - * Initialization of the C package, should not be needed. + * Initialization for the current runtime. */ static void PyThread__init_thread(void) { + // Initialization of the C package should not be needed. } /* @@ -188,8 +189,6 @@ PyThread_start_new_thread(void (*func)(void *), void *arg) unsigned threadID; callobj *obj; - dprintf(("%lu: PyThread_start_new_thread called\n", - PyThread_get_thread_ident())); if (!initialized) PyThread_init_thread(); @@ -209,14 +208,10 @@ PyThread_start_new_thread(void (*func)(void *), void *arg) * too many threads". */ int e = errno; - dprintf(("%lu: PyThread_start_new_thread failed, errno %d\n", - PyThread_get_thread_ident(), e)); threadID = (unsigned)-1; HeapFree(GetProcessHeap(), 0, obj); } else { - dprintf(("%lu: PyThread_start_new_thread succeeded: %p\n", - PyThread_get_thread_ident(), (void*)hThread)); CloseHandle(hThread); } return threadID; @@ -257,7 +252,6 @@ PyThread_get_thread_native_id(void) void _Py_NO_RETURN PyThread_exit_thread(void) { - dprintf(("%lu: PyThread_exit_thread called\n", PyThread_get_thread_ident())); if (!initialized) exit(0); _endthreadex(0); @@ -271,24 +265,22 @@ PyThread_exit_thread(void) PyThread_type_lock PyThread_allocate_lock(void) { - PNRMUTEX aLock; + PNRMUTEX mutex; - dprintf(("PyThread_allocate_lock called\n")); if (!initialized) PyThread_init_thread(); - aLock = AllocNonRecursiveMutex() ; + mutex = AllocNonRecursiveMutex() ; - dprintf(("%lu: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock)); + PyThread_type_lock aLock = (PyThread_type_lock) mutex; + assert(aLock); - return (PyThread_type_lock) aLock; + return aLock; } void PyThread_free_lock(PyThread_type_lock aLock) { - dprintf(("%lu: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); - FreeNonRecursiveMutex(aLock) ; } @@ -307,6 +299,8 @@ PyLockStatus PyThread_acquire_lock_timed(PyThread_type_lock aLock, PY_TIMEOUT_T microseconds, int intr_flag) { + assert(aLock); + /* Fow now, intr_flag does nothing on Windows, and lock acquires are * uninterruptible. */ PyLockStatus success; @@ -333,20 +327,14 @@ PyThread_acquire_lock_timed(PyThread_type_lock aLock, milliseconds = INFINITE; } - dprintf(("%lu: PyThread_acquire_lock_timed(%p, %lld) called\n", - PyThread_get_thread_ident(), aLock, microseconds)); - - if (aLock && EnterNonRecursiveMutex((PNRMUTEX)aLock, - (DWORD)milliseconds) == WAIT_OBJECT_0) { + if (EnterNonRecursiveMutex((PNRMUTEX)aLock, + (DWORD)milliseconds) == WAIT_OBJECT_0) { success = PY_LOCK_ACQUIRED; } else { success = PY_LOCK_FAILURE; } - dprintf(("%lu: PyThread_acquire_lock(%p, %lld) -> %d\n", - PyThread_get_thread_ident(), aLock, microseconds, success)); - return success; } int @@ -358,10 +346,8 @@ PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag) void PyThread_release_lock(PyThread_type_lock aLock) { - dprintf(("%lu: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); - - if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock))) - dprintf(("%lu: Could not PyThread_release_lock(%p) error: %ld\n", PyThread_get_thread_ident(), aLock, GetLastError())); + assert(aLock); + (void)LeaveNonRecursiveMutex((PNRMUTEX) aLock); } /* minimum/maximum thread stack sizes supported */ |
