See the comment above the function--we can't just use `$.when` because new promises might be added to the list during processing.