Skip to content

Commit

Permalink
do not use Thread.Atomic variables (not supported everywhere)
Browse files Browse the repository at this point in the history
It's probably not crucial for this functionality to have atomicity.
  • Loading branch information
rfourquet committed Aug 15, 2017
1 parent bc3a732 commit 3ba15cc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions base/repl/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ complete_line(c::EmptyCompletionProvider, s) = [], true, true
terminal(s::IO) = s
terminal(s::PromptState) = s.terminal

const beeping = Threads.Atomic{Float64}(0.0)
const beeping = Ref(0.0)

function beep(s::PromptState, duration=0.2, blink=0.2, maxduration=1.0;
colors=[Base.text_colors[:light_black]],
use_current::Bool=true,
underline::Bool=false)

Threads.atomic_add!(beeping, min(duration, maxduration-beeping[]))
beeping[] = min(beeping[]+duration, maxduration)
@async begin
trylock(BEEP_LOCK) || return
orig_prefix = s.p.prompt_prefix
Expand All @@ -109,7 +109,7 @@ function beep(s::PromptState, duration=0.2, blink=0.2, maxduration=1.0;
s.p.prompt_prefix = prefix
refresh_multi_line(s)
sleep(blink)
Threads.atomic_sub!(beeping, blink)
beeping[] -= blink
end
s.p.prompt_prefix = orig_prefix
refresh_multi_line(s)
Expand Down

0 comments on commit 3ba15cc

Please sign in to comment.