Doesn't it make sense to manage everything outside ninja-build?
For instance, by wrapping ld with a script that locks an ipc semaphore before calling the real ld?
Here are some ideas on how to simplify it.
1) You can use one variable name to specify the pool in all contexts:
rule cc
pool = foobar
build bar: cc blah # uses foobar pool, inherited from "cc"
build bar2: cc blah2
pool = foobar2 # uses foobar2 pool
At edge evaluation time, evaluating "pool" will either get the value
set in the build block, or fall back on the rule value. You can also
set pool to the empty string to effectively unset it.
See the discussion of variable shadowing here (and linked from there):
http://martine.github.com/ninja/manual.html#_build_statements
2) Rather than extend the syntax with a pool statement, here's a hacky
way to keep the change smaller -- put the pool depth in the pool name.
It won't work for extending to those other ideas but we're not sure
we need them yet and we still can add them via your syntax if
necessary.
rule cc
pool = foobar/10 # the /10 means "10 slots total"
# perhaps default to a depth of 1 if there's no /X ending
rule cc_other:
pool = foobar/10 # must match the other name to share the same pool
It's maybe fragile in that if you typo a name they don't share a pool
but this is also a pretty obscure corner where it's unlikely you'll
ever need more than one or two pools.
3) Regarding consumption: make 1 the default, so it can be left unspecified.
In fact, until someone needs it maybe just don't include it at all.
4) It might make sense to put all jobs that don't name a pool
specifically into some "default" pool that has unlimited depth. This
might simplify the code related to scheduling since everything comes
from a pool.
5) I would skip the priority queue stuff for now. We experimented
with different orderings of builds in Chrome a while back and found
they had counterintuitive effects on end-to-end build time; it'd be a
pain if your pool patch was good but ended up regressing performance
just because you changed how builds were ordered.
That is to say, I think it'd be neat to experiment with priority
ordering in Ninja, I just think you should keep it separate so that we
can measure its effects separately.