Skip to content

Commit bbe5a84

Browse files
committed
Merge pull request #10886 from JuliaLang/cjh/fix-10855
timedwait, sleep now validate arguments
2 parents a989d36 + f014754 commit bbe5a84

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

base/multi.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,7 @@ end
15231523

15241524

15251525
function timedwait(testcb::Function, secs::Float64; pollint::Float64=0.1)
1526+
pollint > 0 || throw(ArgumentError("cannot set pollint to $pollint seconds"))
15261527
start = time()
15271528
done = RemoteRef()
15281529
timercb(aw) = begin

base/stream.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ function stop_timer(timer::Timer)
520520
end
521521

522522
function sleep(sec::Real)
523+
sec 0 || throw(ArgumentError("cannot sleep for $sec seconds"))
523524
w = Condition()
524525
timer = Timer(function (tmr)
525526
notify(w)

test/parallel.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ workloads = hist(@parallel((a,b)->[a;b], for i=1:7; myid(); end), nprocs())[2]
140140
@test isready(rr1)
141141
end
142142

143+
@test_throws ArgumentError sleep(-1)
144+
@test_throws ArgumentError timedwait(()->false, 0.1, pollint=-0.5)
145+
143146
# specify pids for pmap
144147
@test sort(workers()[1:2]) == sort(unique(pmap(x->(sleep(0.1);myid()), 1:10, pids = workers()[1:2])))
145148

0 commit comments

Comments
 (0)