Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop compensating for early Timer in libuv #57264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions base/asyncevent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ mutable struct Timer
function Timer(timeout::Real; interval::Real = 0.0)
timeout ≥ 0 || throw(ArgumentError("timer cannot have negative timeout of $timeout seconds"))
interval ≥ 0 || throw(ArgumentError("timer cannot have negative repeat interval of $interval seconds"))
# libuv has a tendency to timeout 1 ms early, so we need +1 on the timeout (in milliseconds), unless it is zero
timeoutms = ceil(UInt64, timeout * 1000) + !iszero(timeout)
timeoutms = ceil(UInt64, timeout * 1000)
intervalms = ceil(UInt64, interval * 1000)
loop = eventloop()

Expand All @@ -139,7 +138,7 @@ end
function getproperty(t::Timer, f::Symbol)
if f == :timeout
t.timeout_ms == 0 && return 0.0
return (t.timeout_ms - 1) / 1000 # remove the +1ms compensation from the constructor
return t.timeout_ms / 1000
elseif f == :interval
return t.interval_ms / 1000
else
Expand Down