Skip to content

Commit 61568d6

Browse files
committed
previewchan: take! everything at once (old entries don't matter)
1 parent 69176b7 commit 61568d6

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/ReTest.jl

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,15 @@ function retest(args::Union{Module,AbstractString,Regex}...;
404404
gotprinted = false
405405
align_overflow = 0
406406

407+
function take_latest!(previewchan)
408+
local desc
409+
while isready(previewchan)
410+
# printer/previewer can't take! it, as we locked
411+
desc = take!(previewchan)
412+
end
413+
@isdefined(desc) ? desc : ""
414+
end
415+
407416
previewer = previewchan === nothing ? nothing :
408417
@async begin
409418
timer = ['|', '/', '-', '\\']
@@ -413,13 +422,11 @@ function retest(args::Union{Module,AbstractString,Regex}...;
413422

414423
while !finito
415424
lock(printlock) do
416-
if isready(previewchan)
417-
# printer can't take! it, as we locked
418-
newdesc = take!(previewchan)
419-
if newdesc === nothing
420-
finito = true
421-
return
422-
end
425+
newdesc = take_latest!(previewchan)
426+
if newdesc === nothing
427+
finito = true
428+
return # no need to sleep before looping
429+
elseif newdesc != ""
423430
desc = newdesc
424431
cursor = 0
425432
gotprinted = false
@@ -494,8 +501,8 @@ function retest(args::Union{Module,AbstractString,Regex}...;
494501
while !finito
495502
rts = take!(outchan)
496503
lock(printlock) do
497-
if previewchan !== nothing && isready(previewchan)
498-
desc = take!(previewchan)
504+
if previewchan !== nothing
505+
desc = take_latest!(previewchan)
499506
if desc === nothing
500507
# keep `nothing` in so that the previewer knows to terminate
501508
put!(previewchan, nothing)

0 commit comments

Comments
 (0)