|
Ninja
|
A Jobserver::Client instance models a client of an external GNU jobserver pool, which can be implemented as a Unix FIFO, or a Windows named semaphore. More...
#include <jobserver.h>
Public Member Functions | |
| virtual void | Release (Slot slot) |
| Release a slot to the pool. More... | |
| virtual Slot | TryAcquire () |
| Try to acquire a slot from the pool. More... | |
| virtual | ~Client () |
Static Public Member Functions | |
| static std::unique_ptr< Client > | Create (const Config &, std::string *error) |
| Create a new Client instance from a given configuration. More... | |
Protected Member Functions | |
| Client ()=default | |
A Jobserver::Client instance models a client of an external GNU jobserver pool, which can be implemented as a Unix FIFO, or a Windows named semaphore.
Usage is the following:
Definition at line 189 of file jobserver.h.
|
inlinevirtual |
Definition at line 191 of file jobserver.h.
|
protecteddefault |
|
static |
Create a new Client instance from a given configuration.
On failure, this returns null after setting |*error|. Note that it is an error to call this function with |config.HasMode() == false|.
Definition at line 119 of file jobserver-posix.cc.
References Jobserver::Config::kModePosixFifo, Jobserver::Config::mode, and Jobserver::Config::path.
Referenced by TEST().
|
inlinevirtual |
Release a slot to the pool.
Does nothing if slot is invalid, or if writing to the pool fails (and if this is not the implicit slot). If the pool is destroyed before Ninja, then only the implicit slot can be acquired in the next calls (if it was released). This simply enforces serialization of all commands, instead of blocking.
Definition at line 208 of file jobserver.h.
Referenced by RealCommandRunner::ClearJobTokens().
|
inlinevirtual |
Try to acquire a slot from the pool.
On failure, i.e. if no slot can be acquired, this returns an invalid Token instance.
Note that this will always return the implicit slot value the first time this is called, without reading anything from the pool, as specified by the protocol. This implicit value must be released just like any other one. In general, users of this class should not care about this detail, except unit-tests.
Definition at line 201 of file jobserver.h.