Ninja
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Jobserver::Slot Struct Reference

A Jobserver::Slot models a single job slot that can be acquired from. More...

#include <jobserver.h>

Public Member Functions

uint8_t GetExplicitValue () const
 Return value of an explicit slot. More...
 
bool IsExplicit () const
 Return true if this instance represents an explicit job slot. More...
 
bool IsImplicit () const
 Return true if this instance represents an implicit job slot. More...
 
bool IsValid () const
 Return true if this instance is valid, i.e. More...
 
Slotoperator= (const Slot &)=delete
 
Slotoperator= (Slot &&o) noexcept
 
 Slot ()=default
 Default constructor creates invalid instance. More...
 
 Slot (const Slot &)=delete
 Copy operations are disallowed. More...
 
 Slot (Slot &&o) noexcept
 Move operations are allowed. More...
 

Static Public Member Functions

static Slot CreateExplicit (uint8_t value)
 Create instance for explicit byte value. More...
 
static Slot CreateImplicit ()
 Create instance for the implicit value. More...
 

Private Member Functions

 Slot (int16_t value)
 

Private Attributes

int16_t value_ = -1
 

Static Private Attributes

static constexpr int16_t kImplicitValue = 256
 

Detailed Description

A Jobserver::Slot models a single job slot that can be acquired from.

or released to a jobserver pool. This class is move-only, and can wrap three types of values:

Use IsValid(), IsImplicit(), HasValue() to test for categories.

TECHNICAL NOTE: This design complies with the requirements laid out on https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html which requires clients to write back the exact token values they received from a Posix pipe.

Note that currently all pool implementations write the same token values to the pipe ('+' for GNU Make, and '|' for the Rust jobserver), and do not care about the values written back by clients.

Definition at line 55 of file jobserver.h.

Constructor & Destructor Documentation

◆ Slot() [1/4]

Jobserver::Slot::Slot ( )
default

Default constructor creates invalid instance.

Referenced by CreateExplicit(), and CreateImplicit().

◆ Slot() [2/4]

Jobserver::Slot::Slot ( Slot &&  o)
inlinenoexcept

Move operations are allowed.

Definition at line 60 of file jobserver.h.

◆ Slot() [3/4]

Jobserver::Slot::Slot ( const Slot )
delete

Copy operations are disallowed.

◆ Slot() [4/4]

Jobserver::Slot::Slot ( int16_t  value)
inlineprivate

Definition at line 97 of file jobserver.h.

Member Function Documentation

◆ CreateExplicit()

static Slot Jobserver::Slot::CreateExplicit ( uint8_t  value)
inlinestatic

Create instance for explicit byte value.

Definition at line 89 of file jobserver.h.

References Slot().

Referenced by TEST().

◆ CreateImplicit()

static Slot Jobserver::Slot::CreateImplicit ( )
inlinestatic

Create instance for the implicit value.

Definition at line 94 of file jobserver.h.

References kImplicitValue, and Slot().

Referenced by TEST().

◆ GetExplicitValue()

uint8_t Jobserver::Slot::GetExplicitValue ( ) const

Return value of an explicit slot.

It is a runtime error to call this from an invalid instance.

Definition at line 64 of file jobserver.cc.

References IsExplicit(), and value_.

Referenced by TEST().

◆ IsExplicit()

bool Jobserver::Slot::IsExplicit ( ) const
inline

Return true if this instance represents an explicit job slot.

Definition at line 82 of file jobserver.h.

References IsImplicit(), and IsValid().

Referenced by GetExplicitValue(), and TEST().

◆ IsImplicit()

bool Jobserver::Slot::IsImplicit ( ) const
inline

Return true if this instance represents an implicit job slot.

Definition at line 79 of file jobserver.h.

References kImplicitValue, and value_.

Referenced by IsExplicit(), and TEST().

◆ IsValid()

bool Jobserver::Slot::IsValid ( ) const
inline

Return true if this instance is valid, i.e.

that it is either implicit or explicit job slot.

Definition at line 76 of file jobserver.h.

References value_.

Referenced by Plan::FindWork(), IsExplicit(), and TEST().

◆ operator=() [1/2]

Slot& Jobserver::Slot::operator= ( const Slot )
delete

◆ operator=() [2/2]

Slot& Jobserver::Slot::operator= ( Slot &&  o)
inlinenoexcept

Definition at line 62 of file jobserver.h.

References value_.

Member Data Documentation

◆ kImplicitValue

const int16_t Jobserver::Slot::kImplicitValue = 256
staticconstexprprivate

Definition at line 99 of file jobserver.h.

Referenced by CreateImplicit(), and IsImplicit().

◆ value_

int16_t Jobserver::Slot::value_ = -1
private

Definition at line 101 of file jobserver.h.

Referenced by GetExplicitValue(), IsImplicit(), IsValid(), and operator=().


The documentation for this struct was generated from the following files: