Fixed background parallel processes to have a configurable maximum number

This commit is contained in:
Ryan L McIntyre 2016-11-06 17:04:53 -05:00
parent b51e71f746
commit cf010a5035

View file

@ -21,6 +21,7 @@ total_count=0
last_parent_dir=""
unpatched_parent_dir="bin/scripts/../../src/unpatched-fonts"
patched_parent_dir="patched-fonts"
max_parallel_process=64
if [ $# -eq 1 ]
@ -82,10 +83,11 @@ function patch_font {
exit 1
}
fontforge -quiet -script ./font-patcher "$f" -q $powerline --complete --no-progressbars--outputdir "${patched_font_dir}complete/" 2>/dev/null &
fontforge -quiet -script ./font-patcher "$f" -q -s $powerline --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null &
fontforge -quiet -script ./font-patcher "$f" -q -w $powerline --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null &
fontforge -quiet -script ./font-patcher "$f" -q -s -w $powerline --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null &
fontforge -quiet -script ./font-patcher "$f" -q $powerline --complete --no-progressbars--outputdir "${patched_font_dir}complete/" 2>/dev/null
fontforge -quiet -script ./font-patcher "$f" -q -s $powerline --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null
fontforge -quiet -script ./font-patcher "$f" -q -w $powerline --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null
fontforge -quiet -script ./font-patcher "$f" -q -s -w $powerline --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null
# wait for this group of background processes to finish to avoid forking too many processes
# that can add up quickly with the number of combinations
#wait
@ -142,16 +144,25 @@ function generate_readme {
} >> "$combinations_filename"
}
# Use for loop iterate through source fonts
# $f stores current value
for f in "${source_fonts[@]}"
# Iterate through source fonts
for i in "${!source_fonts[@]}"
do
patch_font "$f"
patch_font "${source_fonts[$i]}" "$i" 2>/dev/null &
echo "complete_variation_count after bg proc is $complete_variation_count"
# un-comment to test this script (patch 1 font)
#break
# wait for this set of bg commands to finish: dont do too many at once!
#wait
# if we spawn a background process for each set of fonts it will
# end up using too many system resources
# however we want to run a certain number in parallel to decrease
# the amount of time patching all the fonts will take
# for now set a 'wait' for each X set of processes:
if [[ $(($i % $max_parallel_process)) == 0 ]];
then
wait
fi
done
# wait for all bg commands to finish
wait