VLink  2.0.0
A high-performance communication middleware
vlink::CancellationRegistration Class Referencefinal

Move-only RAII handle that represents one subscribed cancellation callback. More...

#include <cancellation.h>

Collaboration diagram for vlink::CancellationRegistration:

Public Member Functions

 CancellationRegistration () noexcept
 Constructs an empty registration that owns no callback slot. More...
 
 ~CancellationRegistration ()
 Destructor; detaches the owned callback when cancellation has not yet fired. More...
 
 CancellationRegistration (CancellationRegistration &&other) noexcept
 Move constructor; transfers slot ownership and leaves other empty. More...
 
CancellationRegistrationoperator= (CancellationRegistration &&other) noexcept
 Move assignment; detaches any current slot then adopts other 's slot. More...
 
void reset () noexcept
 Detaches the owned callback and resets to the empty state. More...
 
bool valid () const noexcept
 Reports whether the registration still owns an attached callback slot. More...
 

Friends

class CancellationToken
 
class CancellationSource
 

Detailed Description

Move-only RAII handle that represents one subscribed cancellation callback.

Each registration owns exactly one slot inside the source's state. Destroying or reset-ing the handle detaches the callback if it has not yet fired; once the source has cancelled the slot is consumed automatically and the handle becomes a benign no-op sink. The type is deliberately move-only to keep slot identity unique.

Constructor & Destructor Documentation

◆ CancellationRegistration() [1/2]

vlink::CancellationRegistration::CancellationRegistration ( )
noexcept

Constructs an empty registration that owns no callback slot.

◆ ~CancellationRegistration()

vlink::CancellationRegistration::~CancellationRegistration ( )

Destructor; detaches the owned callback when cancellation has not yet fired.

◆ CancellationRegistration() [2/2]

vlink::CancellationRegistration::CancellationRegistration ( CancellationRegistration &&  other)
noexcept

Move constructor; transfers slot ownership and leaves other empty.

Parameters
otherSource registration emptied by the move.

Member Function Documentation

◆ operator=()

CancellationRegistration& vlink::CancellationRegistration::operator= ( CancellationRegistration &&  other)
noexcept

Move assignment; detaches any current slot then adopts other 's slot.

Parameters
otherSource registration emptied by the move.
Returns
Reference to *this.

◆ reset()

void vlink::CancellationRegistration::reset ( )
noexcept

Detaches the owned callback and resets to the empty state.

Idempotent. Safe to call on an empty or already-reset registration.

◆ valid()

bool vlink::CancellationRegistration::valid ( ) const
noexcept

Reports whether the registration still owns an attached callback slot.

Returns
true when the slot is live and the source has not yet cancelled.

Friends And Related Function Documentation

◆ CancellationSource

friend class CancellationSource
friend

◆ CancellationToken

friend class CancellationToken
friend

The documentation for this class was generated from the following file: