There is already `shakeThreads` option that controls the maximal number of threads that can be run at the same time. While this is certainly useful, I shall note that there are some `cmd_`s that's already utilizing threading - say, `cmd_ prog -j 5` where `prog` is a C program using pthread.
An enhancement to the existing threading management would be therefore to make Shake aware of the number of the threads a cmd_ will be using. Say shake knows there are 10 threads running, and the configured "shakeThread" is 16, and there is a runnable cmd_ which is marked to be triple-threaded. Shake can then invoke the cmd_, and update the count to 13(instead of 11 as of now).
AFAIK, the only way there can be more than one thread in a shake action is by cmd_. The problem is that the current thread management in shake is action-based. So I guess the cmd_ has to be altered to block in case the threads run out.
Best,
Zesen