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