Skip to content

Commit

Permalink
enhance Timer outer constructor taking callback to accept any valid a…
Browse files Browse the repository at this point in the history
…rgs/kwargs
  • Loading branch information
baumgold committed Jun 1, 2023
1 parent f61bbfb commit e2513d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/asyncevent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ julia> begin
3
```
"""
function Timer(cb::Function, timeout::Real; interval::Real=0.0)
timer = Timer(timeout, interval=interval)
function Timer(cb::Function, timeout; kwargs...)
timer = Timer(timeout; kwargs...)
t = @task begin
unpreserve_handle(timer)
while _trywait(timer)
Expand Down
5 changes: 5 additions & 0 deletions stdlib/Dates/test/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ end

end

@testset "timer" begin
@test hasmethod(Timer, (Period,))
@test hasmethod(Timer, (Function, Period))
end

@testset "timedwait" begin
@test timedwait(() -> false, Second(0); pollint=Millisecond(1)) === :timed_out
end
Expand Down

0 comments on commit e2513d7

Please sign in to comment.