LLVM 22.0.0git
|
The public interface for a jobserver client. More...
#include "llvm/Support/Jobserver.h"
Public Member Functions | |
virtual | ~JobserverClient () |
virtual JobSlot | tryAcquire ()=0 |
Tries to acquire a job slot from the pool. | |
virtual void | release (JobSlot Slot)=0 |
Releases a job slot back to the pool. | |
virtual unsigned | getNumJobs () const =0 |
Returns the number of job slots available, as determined on first use. |
Static Public Member Functions | |
static JobserverClient * | getInstance () |
Returns the singleton instance of the JobserverClient. | |
static void | resetForTesting () |
Resets the singleton instance. For testing purposes only. |
The public interface for a jobserver client.
This client is a lazy-initialized singleton that is created on first use.
Definition at line 135 of file Jobserver.h.
|
virtualdefault |
|
static |
Returns the singleton instance of the JobserverClient.
This is the main entry point for acquiring a jobserver client.
The instance is created on the first call to this function. Returns a nullptr if no jobserver is configured or an error occurs.
It uses a std::call_once to ensure the singleton GJobserver instance is created safely in a multi-threaded environment. On first call, it reads the MAKEFLAGS environment variable, parses it, and attempts to construct and initialize a JobserverClientImpl. If successful, the global instance is stored in GJobserver. Subsequent calls will return the existing instance.
Definition at line 200 of file Jobserver.cpp.
References llvm::dbgs(), llvm::errs(), LLVM_DEBUG, and llvm::toString().
|
pure virtual |
Returns the number of job slots available, as determined on first use.
This value is cached. Returns 0 if no jobserver is active.
Implemented in llvm::JobserverClientImpl.
|
pure virtual |
Releases a job slot back to the pool.
Implemented in llvm::JobserverClientImpl.
|
static |
Resets the singleton instance. For testing purposes only.
For testing purposes only.
This function resets the singleton instance by destroying the existing client and re-initializing the std::once_flag. This allows tests to simulate the first-time initialization of the jobserver client multiple times.
Definition at line 253 of file Jobserver.cpp.
|
pure virtual |
Tries to acquire a job slot from the pool.
On failure (e.g., if the pool is empty), this returns an invalid JobSlot instance. The first successful call will always return the implicit slot.
Implemented in llvm::JobserverClientImpl.