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
56
plug.vim
56
plug.vim
|
@ -344,40 +344,38 @@ 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
|
while pair = take1.call
|
||||||
}
|
name = pair.first
|
||||||
VIM::evaluate('a:threads').to_i.times.map { |i|
|
dir, uri, branch = pair.last.values_at *%w[dir uri branch]
|
||||||
Thread.new(i) do |ii|
|
ok, result =
|
||||||
while pair = take1.call
|
if File.directory? dir
|
||||||
name = pair.first
|
current_uri = `#{cd} #{dir} && git config remote.origin.url`.chomp
|
||||||
dir, uri, branch = pair.last.values_at *%w[dir uri branch]
|
if $? == 0 && current_uri == uri
|
||||||
ok, result =
|
if pull
|
||||||
if File.directory? dir
|
[true, `#{cd} #{dir} && git checkout -q #{branch} && git pull origin #{branch} 2>&1`]
|
||||||
current_uri = `#{cd} #{dir} && git config remote.origin.url`.chomp
|
else
|
||||||
if $? == 0 && current_uri == uri
|
[true, skip]
|
||||||
if pull
|
end
|
||||||
[true, `#{cd} #{dir} && git checkout -q #{branch} && git pull origin #{branch} 2>&1`]
|
|
||||||
else
|
else
|
||||||
[true, skip]
|
[false, "PlugClean required. Invalid remote."]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
[false, "PlugClean required. Invalid remote."]
|
FileUtils.mkdir_p(base)
|
||||||
|
r = `#{cd} #{base} && git clone --recursive #{uri} -b #{branch} #{dir} 2>&1`
|
||||||
|
[$? == 0, r]
|
||||||
end
|
end
|
||||||
else
|
result = result.lines.to_a.last.strip
|
||||||
FileUtils.mkdir_p(base)
|
log.call name, result, ok
|
||||||
r = `#{cd} #{base} && git clone --recursive #{uri} -b #{branch} #{dir} 2>&1`
|
end
|
||||||
[$? == 0, r]
|
|
||||||
end
|
|
||||||
result = result.lines.to_a.last.strip
|
|
||||||
log.call name, result, ok
|
|
||||||
refill.call name
|
|
||||||
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 a new issue