2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-28 11:57:34 +00:00

Reduce calls to _monotonic_time

iowaiter overhead can be significantly reduced by not calling
monotonic_time() for every single one that is waiting.

Change-Id: I7ee5cd78541d722f4a11898dcd4a3390b8220a95
This commit is contained in:
Jarrod Johnson 2018-08-16 08:28:33 -04:00
parent f1bea21cf1
commit 2c25baf4ca

View File

@ -124,8 +124,9 @@ def define_worker():
# deadline if they still have time waiting, or
# if they have expired, wake them now to let them
# process their timeout
rightnow = _monotonic_time()
for idx, w in enumerate(list(directediowaiters[d])):
ltimeout = w[0] - _monotonic_time()
ltimeout = w[0] - rightnow
if ltimeout < 0:
w[1].set() # time is up, wake the caller
del directediowaiters[d][idx]