michaelforney / samurai

ninja-compatible build tool written in C
Other
824 stars 46 forks source link

Support for GNU Make jobserver (alternative implementation) #104

Open bonzini opened 5 months ago

bonzini commented 5 months ago

Alternative implementation to #94.

The main advantage is that the integration with the build() event loop is very clean, as it simply uses a pipe to signal the availability of tokens. Interacting with the job server is entirely embedded within a new token.c file that implements a simple API:

int tokeninit(void);
bool tokenget(struct edge *e);
void tokenput(void);

and on top of this, the integration is about 20 lines of code.

On the other hand token.c uses pthreads, which perhaps could be considered less appealing. Waiting for reviews. :)

bonzini commented 4 months ago

(rebased on top of #106, which provides "give back tokens on signals" behavior for free)