mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
gh-88750: On Windows, PyThread_acquire_lock() no longer checks for NULL (#92586)
On Windows, PyThread_acquire_lock(), PyThread_acquire_lock_timed() and PyThread_release_lock() no longer check at runtime if the lock is not NULL.
This commit is contained in:
parent
6ed7c353b8
commit
cb35402c18
1 changed files with 12 additions and 8 deletions
|
@ -264,14 +264,17 @@ PyThread_exit_thread(void)
|
||||||
PyThread_type_lock
|
PyThread_type_lock
|
||||||
PyThread_allocate_lock(void)
|
PyThread_allocate_lock(void)
|
||||||
{
|
{
|
||||||
PNRMUTEX aLock;
|
PNRMUTEX mutex;
|
||||||
|
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
PyThread_init_thread();
|
PyThread_init_thread();
|
||||||
|
|
||||||
aLock = AllocNonRecursiveMutex() ;
|
mutex = AllocNonRecursiveMutex() ;
|
||||||
|
|
||||||
return (PyThread_type_lock) aLock;
|
PyThread_type_lock aLock = (PyThread_type_lock) mutex;
|
||||||
|
assert(aLock);
|
||||||
|
|
||||||
|
return aLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -295,6 +298,8 @@ PyLockStatus
|
||||||
PyThread_acquire_lock_timed(PyThread_type_lock aLock,
|
PyThread_acquire_lock_timed(PyThread_type_lock aLock,
|
||||||
PY_TIMEOUT_T microseconds, int intr_flag)
|
PY_TIMEOUT_T microseconds, int intr_flag)
|
||||||
{
|
{
|
||||||
|
assert(aLock);
|
||||||
|
|
||||||
/* Fow now, intr_flag does nothing on Windows, and lock acquires are
|
/* Fow now, intr_flag does nothing on Windows, and lock acquires are
|
||||||
* uninterruptible. */
|
* uninterruptible. */
|
||||||
PyLockStatus success;
|
PyLockStatus success;
|
||||||
|
@ -321,7 +326,7 @@ PyThread_acquire_lock_timed(PyThread_type_lock aLock,
|
||||||
milliseconds = INFINITE;
|
milliseconds = INFINITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aLock && EnterNonRecursiveMutex((PNRMUTEX)aLock,
|
if (EnterNonRecursiveMutex((PNRMUTEX)aLock,
|
||||||
(DWORD)milliseconds) == WAIT_OBJECT_0) {
|
(DWORD)milliseconds) == WAIT_OBJECT_0) {
|
||||||
success = PY_LOCK_ACQUIRED;
|
success = PY_LOCK_ACQUIRED;
|
||||||
}
|
}
|
||||||
|
@ -340,10 +345,9 @@ PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
|
||||||
void
|
void
|
||||||
PyThread_release_lock(PyThread_type_lock aLock)
|
PyThread_release_lock(PyThread_type_lock aLock)
|
||||||
{
|
{
|
||||||
if (aLock) {
|
assert(aLock);
|
||||||
(void)LeaveNonRecursiveMutex((PNRMUTEX) aLock);
|
(void)LeaveNonRecursiveMutex((PNRMUTEX) aLock);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* minimum/maximum thread stack sizes supported */
|
/* minimum/maximum thread stack sizes supported */
|
||||||
#define THREAD_MIN_STACKSIZE 0x8000 /* 32 KiB */
|
#define THREAD_MIN_STACKSIZE 0x8000 /* 32 KiB */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue