Skip to content

ActiveInstance

Source: ActiveInstance.h

ActiveInstance

template<class T>
class ActiveInstance
src/core/util/ActiveInstance.h:31

Public Methods

inline explicit ActiveInstance(T & self) : Declared as a member of the instance it seats.

inline ~ActiveInstance() : Vacates when this instance holds the seat, which is the dangling-pointer guard.

ActiveInstance(const ActiveInstance &) = delete : Non-copyable: the seat is tied to one instance by reference.

ActiveInstance(ActiveInstance &&) = delete : Non-movable, for the same reason: relocating it would dangle.

inline void claim() : Take the seat when it is empty, the first live instance winning: [why calling it again is safe].

inline void vacate() : Give up the seat, but only if this instance holds it (never yanks another's seat).

inline bool seated() const : Does this instance currently hold the seat?

Public Static Methods

static inline T * active() : The one live winner, or nullptr when the seat is empty. Consumers null-check.