sync.atomic.init


class init_once §source

Holds a boolean state which is initially set to false and flipped to true by the first call to check method.

Methods

  • bool check() §source
    

    The first call returns false and all subsequent calls return true.

template <auto Width>
inline pair<bool, uint<Width>> init_generational(bool reset) §source

Amortize the cost of initializing a set of variables by assigning a generation ID to each variable. A variable is considered uninitialized if the associated generation ID does not match the current generation ID. Per-variable generation IDs only need to be initialized when the current generation ID overflows.

The returned pair first field is true if the generation ID has overflowed and an explicit initialization to a generation ID of 0 is required.

The returned pair second field is the generation ID to compare against.

reset must be true on the first call to this function.

Parameters

  • auto Width
    

    Number of bits in a generation ID. Higher values result in fewer initializations.