summaryrefslogtreecommitdiffstats
path: root/Python/lock.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-05-05 10:15:19 (GMT)
committerGitHub <noreply@github.com>2024-05-05 10:15:19 (GMT)
commitaa61f8bfcf2584dd8345f1f9a07e240100b79192 (patch)
treedb196e9316a20ff332290c56b60c38a6b533fae6 /Python/lock.c
parentc7c9b913c01afb8d2ff4048f82155969f7ef75b1 (diff)
downloadcpython-aa61f8bfcf2584dd8345f1f9a07e240100b79192.zip
cpython-aa61f8bfcf2584dd8345f1f9a07e240100b79192.tar.gz
cpython-aa61f8bfcf2584dd8345f1f9a07e240100b79192.tar.bz2
gh-110850: Remove _PyTime_TimeUnchecked() function (#118552)
Use the new public Raw functions: * _PyTime_PerfCounterUnchecked() with PyTime_PerfCounterRaw() * _PyTime_TimeUnchecked() with PyTime_TimeRaw() * _PyTime_MonotonicUnchecked() with PyTime_MonotonicRaw() Remove internal functions: * _PyTime_PerfCounterUnchecked() * _PyTime_TimeUnchecked() * _PyTime_MonotonicUnchecked()
Diffstat (limited to 'Python/lock.c')
-rw-r--r--Python/lock.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/Python/lock.c b/Python/lock.c
index 5ed95fc..239e56a 100644
--- a/Python/lock.c
+++ b/Python/lock.c
@@ -5,13 +5,13 @@
#include "pycore_lock.h"
#include "pycore_parking_lot.h"
#include "pycore_semaphore.h"
-#include "pycore_time.h" // _PyTime_MonotonicUnchecked()
+#include "pycore_time.h" // _PyTime_Add()
#ifdef MS_WINDOWS
# define WIN32_LEAN_AND_MEAN
-# include <windows.h> // SwitchToThread()
+# include <windows.h> // SwitchToThread()
#elif defined(HAVE_SCHED_H)
-# include <sched.h> // sched_yield()
+# include <sched.h> // sched_yield()
#endif
// If a thread waits on a lock for longer than TIME_TO_BE_FAIR_NS (1 ms), then
@@ -66,7 +66,9 @@ _PyMutex_LockTimed(PyMutex *m, PyTime_t timeout, _PyLockFlags flags)
return PY_LOCK_FAILURE;
}
- PyTime_t now = _PyTime_MonotonicUnchecked();
+ PyTime_t now;
+ // silently ignore error: cannot report error to the caller
+ (void)PyTime_MonotonicRaw(&now);
PyTime_t endtime = 0;
if (timeout > 0) {
endtime = _PyTime_Add(now, timeout);
@@ -143,7 +145,9 @@ mutex_unpark(PyMutex *m, struct mutex_entry *entry, int has_more_waiters)
{
uint8_t v = 0;
if (entry) {
- PyTime_t now = _PyTime_MonotonicUnchecked();
+ PyTime_t now;
+ // silently ignore error: cannot report error to the caller
+ (void)PyTime_MonotonicRaw(&now);
int should_be_fair = now > entry->time_to_be_fair;
entry->handed_off = should_be_fair;