mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-41710: Add private _PyDeadline_Get() function (GH-28674)
Add a private C API for deadlines: add _PyDeadline_Init() and _PyDeadline_Get() functions. * Add _PyTime_Add() and _PyTime_Mul() functions which compute t1+t2 and t1*t2 and clamp the result on overflow. * _PyTime_MulDiv() now uses _PyTime_Add() and _PyTime_Mul().
This commit is contained in:
parent
54957f16a6
commit
833fdf126c
11 changed files with 177 additions and 109 deletions
|
|
@ -84,13 +84,12 @@ lock_dealloc(lockobject *self)
|
|||
static PyLockStatus
|
||||
acquire_timed(PyThread_type_lock lock, _PyTime_t timeout)
|
||||
{
|
||||
PyLockStatus r;
|
||||
_PyTime_t endtime = 0;
|
||||
|
||||
if (timeout > 0) {
|
||||
endtime = _PyTime_GetMonotonicClock() + timeout;
|
||||
endtime = _PyDeadline_Init(timeout);
|
||||
}
|
||||
|
||||
PyLockStatus r;
|
||||
do {
|
||||
_PyTime_t microseconds;
|
||||
microseconds = _PyTime_AsMicroseconds(timeout, _PyTime_ROUND_CEILING);
|
||||
|
|
@ -114,7 +113,7 @@ acquire_timed(PyThread_type_lock lock, _PyTime_t timeout)
|
|||
/* If we're using a timeout, recompute the timeout after processing
|
||||
* signals, since those can take time. */
|
||||
if (timeout > 0) {
|
||||
timeout = endtime - _PyTime_GetMonotonicClock();
|
||||
timeout = _PyDeadline_Get(endtime);
|
||||
|
||||
/* Check for negative values, since those mean block forever.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue