diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2021-01-25 19:33:01 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2021-01-27 15:24:02 +0100 |
commit | ddda48dac8e373f9bc0884ffeb84605925d988e5 (patch) | |
tree | 5a03c1495d0822fac4b566bb8a7afb4d7f618b6a | |
parent | 1b3f13b1ba5a3e40d4c9266f16091ad347aec333 (diff) |
sfeed_update: separate code of parallel exection and feed() into a _feed() handler
This is useful to be able to reuse the code (together with using sfeed_update
as an included script, coming in the next commit).
-rwxr-xr-x | sfeed_update | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/sfeed_update b/sfeed_update index 96f1111..9a729e4 100755 --- a/sfeed_update +++ b/sfeed_update @@ -79,17 +79,10 @@ order() { sort -t ' ' -k1rn,1 } -# fetch and parse feed. -# feed(name, feedurl, [basesiteurl], [encoding]) -feed() { - # wait until ${maxjobs} are finished: will stall the queue if an item - # is slow, but it is portable. - [ ${signo} -ne 0 ] && return - [ $((curjobs % maxjobs)) -eq 0 ] && wait - [ ${signo} -ne 0 ] && return - curjobs=$((curjobs + 1)) - - (name="$1" +# internal handler to fetch and process a feed. +# _feed(name, feedurl, [basesiteurl], [encoding]) +_feed() { + name="$1" feedurl="$2" basesiteurl="$3" encoding="$4" @@ -160,7 +153,19 @@ feed() { # OK log "${name}" "OK" - ) & +} + +# fetch and process a feed in parallel. +# feed(name, feedurl, [basesiteurl], [encoding]) +feed() { + # wait until ${maxjobs} are finished: will stall the queue if an item + # is slow, but it is portable. + [ ${signo} -ne 0 ] && return + [ $((curjobs % maxjobs)) -eq 0 ] && wait + [ ${signo} -ne 0 ] && return + curjobs=$((curjobs + 1)) + + _feed "$@" & } cleanup() { |