Prevent serialization due to early termination of threads
This commit is contained in:
parent
a9d5912b4d
commit
214b4fb6fa
1 changed files with 27 additions and 29 deletions
16
plug.vim
16
plug.vim
|
@ -344,14 +344,10 @@ function! s:update_parallel(pull, threads)
|
|||
logh.call
|
||||
end
|
||||
}
|
||||
refill = proc { |name|
|
||||
mtx.synchronize do
|
||||
all.merge! VIM::evaluate("s:extend(['#{name}'])")
|
||||
logh.call
|
||||
end
|
||||
}
|
||||
VIM::evaluate('a:threads').to_i.times.map { |i|
|
||||
Thread.new(i) do |ii|
|
||||
until all.empty?
|
||||
names = all.keys
|
||||
[names.length, VIM::evaluate('a:threads').to_i].min.times.map { |i|
|
||||
Thread.new(i) do
|
||||
while pair = take1.call
|
||||
name = pair.first
|
||||
dir, uri, branch = pair.last.values_at *%w[dir uri branch]
|
||||
|
@ -374,10 +370,12 @@ function! s:update_parallel(pull, threads)
|
|||
end
|
||||
result = result.lines.to_a.last.strip
|
||||
log.call name, result, ok
|
||||
refill.call name
|
||||
end
|
||||
end
|
||||
}.each(&:join)
|
||||
all.merge! VIM::evaluate("s:extend(#{names.inspect})")
|
||||
logh.call
|
||||
end
|
||||
$curbuf[1] = "Updated. Elapsed time: #{"%.6f" % (Time.now - st)} sec."
|
||||
EOF
|
||||
endfunction
|
||||
|
|
Loading…
Reference in a new issue