-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add Timer
args to struct and add show method
#57081
Add Timer
args to struct and add show method
#57081
Conversation
base/asyncevent.jl
Outdated
@@ -90,6 +90,8 @@ mutable struct Timer | |||
cond::ThreadSynchronizer | |||
@atomic isopen::Bool | |||
@atomic set::Bool | |||
timeout::Real |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should store this as the computed UInt64 milliseconds. It can be printed in seconds with 3 decimals if you like. Not really worth introducing a type instability for this.
base/asyncevent.jl
Outdated
@@ -90,6 +90,8 @@ mutable struct Timer | |||
cond::ThreadSynchronizer | |||
@atomic isopen::Bool | |||
@atomic set::Bool | |||
timeout::Real | |||
interval::Real |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out libuv has an accessor for this, uv_timer_get_repeat
https://docs.libuv.org/en/v1.x/timer.html#c.uv_timer_get_repeat, so we can use that instead of storing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this but it won't work if the timer has been closed
julia> t = Timer(1, interval = 0.1)
Timer (open, timeout: 1.0 s, interval: 0.1 s) @0x000000010cada9b0
julia> close(t)
julia> t
[91257] signal 11 (2): Segmentation fault: 11
in expression starting at REPL[4]:1
uv_timer_get_repeat at /workspace/srcdir/libuv/src/timer.c:120
getproperty at ./asyncevent.jl:126 [inlined]
show at ./asyncevent.jl:135
show at ./multimedia.jl:47
So I've stored both as their ms values.
ea6f9d0
to
8dac283
Compare
This comment was marked as resolved.
This comment was marked as resolved.
6b9103e
to
cbe13dd
Compare
cbe13dd
to
c5c4964
Compare
Makes it possible to access & see the initial setup of a Timer.
This PR
Master