Add an optimal thread strategy to execute specified amount of tasks. This strategy should prevent us from creating too many threads if we occasionaly have an unexpectedly small amount of tasks.
Side-note: @dmantipov Could you please use git diff -U99999 when creating patches? This allows reviewers to quickly browse through other parts of the file(s) in Phabricator. That would fix the "Context not available." message.
The patch looks like a quick win on the short term. A better fix would create threads on-the-go as work is being pushed on the queue. An even better fix would be a system-wide thread pool for all LLVM apps. But that would require more effort, especially on testing & maintenance.