# Background-job pool, throttled to a fixed number of concurrent children. # # A "pool" is encapsulated behind a single handle: a name prefix string. The # helpers derive the pool's four backing variables from that prefix on demand: # # ${pool}_pids indexed array - pids of jobs still being tracked # ${pool}_statuses assoc array - pid -> exit status, for jobs already # reaped by `wait -n` but not yet finished # ${pool}_labels assoc array - pid -> human label, for failure messages # ${pool}_failed integer - 1 once any job has exited non-zero # # Encapsulating the four parallel arrays behind one prefix means callers declare # and pass a single handle instead of four namerefs (each previously needing its # own `shellcheck disable=SC2034`). Bash cannot nest indexed arrays inside an # associative array, so a literal single-variable struct is impossible; a name # prefix with `declare -g` backing variables is the simplest encoding that keeps # all four pieces together under one name while staying pure-nameref (no eval). # # Public API: # job_pool_init - create/reset the four backing variables # job_pool_submit