mirror of
https://github.com/opensiriusfox/bashrc.d.git
synced 2025-06-16 20:31:15 -07:00
added helpers for parallel work.
This commit is contained in:
parent
f6769c725f
commit
3183d36e95
1 changed files with 20 additions and 0 deletions
20
1-parallel-template
Normal file
20
1-parallel-template
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
MAX_JOBS=8
|
||||
function holdForWork() {
|
||||
while [[ $MAX_JOBS -le $(jobs -l | wc -l) ]]; do sleep 0.1; done
|
||||
}
|
||||
function holdForFinish() {
|
||||
while [[ $(jobs -lr | wc -l) -gt 0 ]]; do sleep 0.1; done
|
||||
}
|
||||
|
||||
|
||||
for TASK in TASK_LIST; do
|
||||
holdForWork
|
||||
(
|
||||
echo ""
|
||||
) &>/dev/null &
|
||||
done
|
||||
|
||||
holdForFinish
|
||||
echo " ...done!"
|
Loading…
Add table
Add a link
Reference in a new issue