Skip to content

Commit

Permalink
Simplify lock(DOWNLOAD_LOCK) (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf authored May 17, 2022
1 parent 20e0990 commit 78255d4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Downloads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,12 @@ function request(
throw :: Bool = true,
downloader :: Union{Downloader, Nothing} = nothing,
) :: Union{Response, RequestError}
lock(DOWNLOAD_LOCK) do
yield() # let other downloads finish
downloader isa Downloader && return
while true
if downloader === nothing
lock(DOWNLOAD_LOCK) do
downloader = DOWNLOADER[]
downloader isa Downloader && return
DOWNLOADER[] = Downloader()
if downloader === nothing
downloader = DOWNLOADER[] = Downloader()
end
end
end
local response
Expand Down

0 comments on commit 78255d4

Please sign in to comment.